by adom
Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.
← Commit history
0.2.89 (source, not released): import_design drives Altium's EAGLE Import Wizard (written from the live mapping, not yet run end to end)
5 files changed
+184−26
CHANGELOG.md+7@@ -1,5 +1,12 @@ # Changelog +## 0.2.89 (unreleased)++- **`import_design` reads EAGLE** (EDA Bridge Standard #29): an EAGLE schematic and its board, together, into a new Altium project through Altium's Import Wizard, run outside the script engine with Altium's own import options.+ - How the wizard is driven: the importer list answers no UI Automation, so EAGLE is picked with a real click. The EAGLE wizard's Load dialog takes the file name over UIA and only Enter. The later pages are answered with Next until Finish.+ - `steps` lists every one. `kicad` still goes through Altium's KiCad importer.+ - Written from the live mapping; not yet run end to end (next: the BQ25792 EAGLE pair on DESKTOP-BAR6S0F).+ ## 0.2.88 - **`altium_import_step`** (EDA Bridge Standard #29, native): a STEP placed with the board as free 3D geometry (an enclosure, a bracket, a lid) for fit checks. It is a 3D body of the board itself, on a mechanical layer, belonging to no part (`add_body` puts a model on one footprint).
README.md+1−1@@ -263,7 +263,7 @@ All 270 verbs, by area (prefix `altium_`). `altium_describe` returns the live ca - `altium_edit_pours`: Change existing pours in place, without redrawing them: net, layer, hatching, minimum width, grid, dead copper, islands, necks, pouring over same-net objects and pour order; and clearance and thermals, which Altium keeps as design rules scoped to the polygon. - `altium_export_3d`: The board's 3D model in another format than STEP, by Altium's own exporter (File > Export): Parasolid (.x_t) or VRML (.wrl). - `altium_tool_update`: Altium's own updates.-- `altium_import_design`: Bring a foreign design into a new Altium project: kicad through Altium's KiCad importer.+- `altium_import_design`: Bring a foreign design into a new Altium project: eagle through Altium's Import Wizard (the schematic and its board together), kicad through Altium's KiCad importer. - `altium_export_library_part`: Export one library part into its own small library files: a symbol library with only its symbol, a footprint library with only its footprint, and its 3D model file. - `altium_create_part_project`: Generate a small real project (schematic and board) around one library part, so the part can be shown and tested in every view: schematic, 2D board and 3D board. - `altium_library_views`: Pictures of library parts for review, each as an image file: the schematic symbol, the footprint (pads and layers), the 3D body seated on the footprint, and the device view that maps symbol pins to pads.
bridge-rs/src/importdesign.rs+170−19@@ -1,30 +1,181 @@ //! import_design: a foreign design into a new native Altium project (EDA Bridge Standard #29, native). `kicad` goes-//! through Altium's KiCad importer (import_kicad). Every other format Altium's Import Wizard reads is refused by name-//! until the bridge drives it.+//! through Altium's KiCad importer (import_kicad); `eagle` through Altium's Import Wizard, driven outside the script+//! engine through UI Automation and, where Altium's Delphi controls answer nothing else, a real click or key. Every+//! step is in `steps`. Other formats Altium's wizard reads are refused by name until the bridge drives them. //!-//! EAGLE, mapped live on Altium Designer Develop 26.9 (2026-10-30), for the driver that comes next:-//! - ImporterManager:RunImporterManagerDialog opens "Import Wizard" (TImporterManagerForm). Its pages are panes named-//! Sheet_Start, Sheet_Importer; the buttons Back / Next / Finish / Cancel take UIA Invoke. Run it through the process-//! launcher (outside the script engine) and find it by window title: the dialog scan does not list it.-//! - Sheet_Importer is a grid (Grid_Importer) of importers. "EAGLE Projects and Designs" must be clicked with the mouse:-//! UIA Select does not reach the Delphi grid, and Next then imports the first row, 99SE DDB (which asks to close every-//! document: a Confirm the reaper answers No).-//! - Next hands over to "EAGLE Import Wizard" (TImporterWizardForm): "Importing EAGLE Design Files" (a list with Add /-//! Remove), then "Importing EAGLE Library Files" (.lbr), then pages not yet seen. Add opens "Load EAGLE Designs", an-//! old-style Open dialog: its file name box is automation id 1148 and only Enter takes it (the Open button's UIA-//! Invoke did nothing); a second Add right after the first refused SetValue.+//! EAGLE, as mapped on Altium Designer Develop 26.9 (2026-10-30):+//! - ImporterManager:RunImporterManagerDialog opens "Import Wizard" (TImporterManagerForm); the dialog scan does not+//! list it, so it is found by title. Back / Next / Finish / Cancel take UIA Invoke.+//! - Its importer grid needs a mouse click on "EAGLE Projects and Designs": UIA Select does not reach the Delphi grid,+//! and Next would import the first row, 99SE DDB (which asks to close every document).+//! - Next hands over to "EAGLE Import Wizard" (TImporterWizardForm): design files (Add / Remove), library files, then+//! its later pages, answered with Next until Finish.+//! - Add opens "Load EAGLE Designs", an old-style Open dialog: its file name box (id 1148) takes SetValue, and only+//! Enter takes it. use serde_json::{json, Value};+use std::path::{Path, PathBuf};+use std::time::{Duration, Instant, SystemTime}; -/// altium_import_design {format, filePath}+/// The EAGLE files of a design: the .sch and .brd beside the one named (either may be). Pure apart from the file check.+pub fn eagle_files(path: &str) -> Vec<PathBuf> {+ let p = PathBuf::from(path.replace('\\', "/"));+ let mut out: Vec<PathBuf> = ["sch", "brd"].iter().map(|e| p.with_extension(e)).filter(|f| f.is_file()).collect();+ if out.is_empty() && p.is_file() { out.push(p); }+ out+}++fn ab(verb: &str, args: Value) -> Value { crate::ab::call(verb, args, &[], 20) }+fn ok(r: &Value) -> bool { r.get("success").and_then(|b| b.as_bool()) != Some(false) && r.get("status").and_then(|s| s.as_str()) != Some("error") }++/// A top-level window by title, within `secs`.+fn window(title: &str, secs: u64) -> Option<i64> {+ let t0 = Instant::now();+ while t0.elapsed().as_secs() < secs {+ let r = ab("desktop_find_window", json!({"titleContains": title}));+ let o = if r["output"].is_string() { serde_json::from_str::<Value>(r["output"].as_str().unwrap_or("{}")).unwrap_or(r.clone()) } else { r.clone() };+ if let Some(h) = o["windows"].as_array().and_then(|a| a.iter().find(|w| w["title"].as_str() == Some(title))).and_then(|w| w["hwnd"].as_i64()) { return Some(h); }+ std::thread::sleep(Duration::from_millis(500));+ }+ None+}++/// The UIA tree of a window, flattened: (role, name, automationId, rect centre, node).+fn nodes(h: i64) -> Vec<Value> {+ let r = ab("desktop_ui_tree", json!({"hwnd": h, "maxDepth": 30, "maxNodes": 2000}));+ let mut out = Vec::new();+ fn walk(n: &Value, out: &mut Vec<Value>) { out.push(n.clone()); for c in n["children"].as_array().cloned().unwrap_or_default() { walk(&c, out); } }+ walk(&r["root"], &mut out);+ out+}++fn click(h: i64, name: &str) -> bool { ok(&ab("desktop_ui_click", json!({"hwnd": h, "name": name, "role": "button"}))) }++/// Add one file through the wizard's Load dialog.+fn add_file(wiz: i64, f: &Path, steps: &mut Vec<Value>) -> bool {+ if !click(wiz, "Add") { steps.push(json!({"step": "add", "file": f, "ok": false, "why": "no Add button"})); return false; }+ let Some(load) = window("Load EAGLE Designs", 15) else { steps.push(json!({"step": "add", "file": f, "ok": false, "why": "no Load EAGLE Designs dialog"})); return false; };+ let want = f.to_string_lossy().replace('/', "\\");+ let norm = |v: &str| v.replace('\\', "/").to_ascii_lowercase();+ let mut set = false;+ for _ in 0..5 {+ // the dialog takes a moment to accept a value after it opens+ std::thread::sleep(Duration::from_millis(600));+ ab("desktop_ui_set", json!({"hwnd": load, "name": "File name:", "role": "edit", "text": want}));+ let back = ab("desktop_find_controls", json!({"hwnd": load, "automationId": "1148"}));+ if back["matches"].as_array().map(|a| a.iter().any(|m| m["value"].as_str().map(norm) == Some(norm(&want)))).unwrap_or(false) { set = true; break; }+ }+ if !set { ab("desktop_ui_click", json!({"hwnd": load, "name": "Cancel", "role": "button"})); steps.push(json!({"step": "add", "file": f, "ok": false, "why": "the file name would not take"})); return false; }+ ab("desktop_press_key", json!({"keys": ["enter"], "hwnd": load, "reason": "open the EAGLE file in Altium's import wizard"}));+ let t0 = Instant::now();+ while window("Load EAGLE Designs", 1).is_some() && t0.elapsed().as_secs() < 10 { std::thread::sleep(Duration::from_millis(400)); }+ steps.push(json!({"step": "add", "file": f, "ok": true}));+ true+}++/// The newest .PrjPcb under `dir` (two levels down) written since `since`.+fn new_project(dir: &Path, since: SystemTime) -> Option<PathBuf> {+ let mut best: Option<(SystemTime, PathBuf)> = None;+ let mut walk = vec![(dir.to_path_buf(), 0)];+ while let Some((d, depth)) = walk.pop() {+ for e in std::fs::read_dir(&d).into_iter().flatten().flatten() {+ let p = e.path();+ if p.is_dir() { if depth < 2 { walk.push((p, depth + 1)); } continue; }+ if !p.extension().map(|x| x.eq_ignore_ascii_case("PrjPcb")).unwrap_or(false) { continue; }+ if let Some(m) = e.metadata().and_then(|m| m.modified()).ok().filter(|m| *m >= since) {+ if best.as_ref().map(|b| m > b.0).unwrap_or(true) { best = Some((m, p)); }+ }+ }+ }+ best.map(|b| b.1)+}++/// Close whatever wizard windows are left.+fn cancel_all() {+ for t in ["Load EAGLE Designs", "EAGLE Import Wizard", "Import Wizard"] {+ if let Some(h) = window(t, 1) { if !click(h, "Cancel") { ab("desktop_press_key", json!({"keys": ["escape"], "hwnd": h, "reason": "close the import wizard"})); } }+ }+}++/// The EAGLE import, the agent stopped while it runs.+fn run_eagle(files: &[PathBuf], steps: &mut Vec<Value>) -> Result<(), String> {+ let exe = crate::lifecycle::x2_exe_pub().ok_or("X2.exe not found")?;+ let mut child = crate::lifecycle::spawn_helper_pub(&exe, "-RImporterManager:RunImporterManagerDialog")?;+ let Some(wiz) = window("Import Wizard", 20) else { crate::lifecycle::wait_helper_pub(&mut child, Duration::from_secs(10)); return Err("Altium's Import Wizard did not open".into()); };+ click(wiz, "Next");+ std::thread::sleep(Duration::from_millis(800));+ // the EAGLE row, clicked: the grid answers no UIA pattern+ let row = nodes(wiz).into_iter().find(|n| n["name"].as_str() == Some("EAGLE Projects and Designs"));+ let Some(r) = row.and_then(|n| n["rect"].as_object().cloned()) else { cancel_all(); return Err("no EAGLE row in the Import Wizard's list".into()); };+ let c = ab("desktop_click", json!({"x": r["centerX"], "y": r["centerY"], "hwnd": wiz, "reason": "choose EAGLE in Altium's Import Wizard (its list answers no UI Automation)"}));+ steps.push(json!({"step": "choose_eagle", "ok": ok(&c)}));+ click(wiz, "Next");+ let Some(eagle) = window("EAGLE Import Wizard", 20) else { cancel_all(); return Err("the EAGLE Import Wizard did not open (the importer chosen was not EAGLE)".into()); };+ for f in files { if !add_file(eagle, f, steps) { cancel_all(); return Err(format!("{} could not be added", f.display())); } }+ // the later pages keep Altium's own import options: Finish as soon as it is offered (a greyed Finish takes no+ // Invoke), Next until then+ let mut finished = false;+ for i in 0..12 {+ if click(eagle, "Finish") {+ std::thread::sleep(Duration::from_millis(1500));+ if window("EAGLE Import Wizard", 1).is_none() { steps.push(json!({"step": "finish", "page": i})); finished = true; break; }+ }+ if !click(eagle, "Next") { steps.push(json!({"step": "stuck", "page": i})); break; }+ steps.push(json!({"step": "next", "page": i}));+ std::thread::sleep(Duration::from_millis(1000));+ if window("EAGLE Import Wizard", 1).is_none() { finished = true; break; }+ }+ if !finished { cancel_all(); return Err("the EAGLE Import Wizard never offered Finish".into()); }+ // the import runs after Finish; the launcher returns when it is done+ crate::lifecycle::wait_helper_pub(&mut child, Duration::from_secs(600));+ Ok(())+}++/// altium_import_design {format, filePath, outputDir?} pub fn import_design(args: &Value) -> Value { if let Some(g) = crate::support::need_licensed() { return g; }- let format = crate::support::s(args, "format").unwrap_or_default().to_ascii_lowercase();- if crate::support::s(args, "filePath").is_none() { return json!({"success": false, "errorCode": "bad_args", "error": "filePath (the design to import) is required"}); }+ let s = |k: &str| crate::support::s(args, k);+ let format = s("format").unwrap_or_default().to_ascii_lowercase();+ let Some(path) = s("filePath") else { return json!({"success": false, "errorCode": "bad_args", "error": "filePath (the design to import) is required"}) }; match format.as_str() { "kicad" => { let mut r = crate::outputs::import_kicad(args); r["format"] = json!("kicad"); r }- "" => json!({"success": false, "errorCode": "bad_args", "error": "format is required (kicad)"}),- o => json!({"success": false, "errorCode": "unsupported", "format": o, "formats": ["kicad"],+ "eagle" => {+ let files = eagle_files(&path);+ if files.is_empty() { return json!({"success": false, "errorCode": "file_not_found", "error": format!("no EAGLE .sch or .brd at {path}")}); }+ let dir = s("outputDir").map(PathBuf::from).unwrap_or_else(|| files[0].parent().map(Path::to_path_buf).unwrap_or_default());+ let since = SystemTime::now();+ let stop = crate::lifecycle::stop();+ if stop.get("success").and_then(|v| v.as_bool()) != Some(true) { return json!({"success": false, "errorCode": "agent_stop_failed", "stop": stop}); }+ let mut steps = Vec::new();+ let run = run_eagle(&files, &mut steps);+ let start = crate::lifecycle::start(Duration::from_secs(90));+ let prj = new_project(&dir, since);+ match (run, prj) {+ (Ok(()), Some(p)) => json!({"success": true, "format": "eagle", "files": files, "project": p, "steps": steps, "agentRestarted": start.get("success"),+ "_hint": "Altium's Import Wizard made a new project from the EAGLE schematic and board, with its own import options. Open it with altium_open_project."}),+ (Ok(()), None) => json!({"success": false, "errorCode": "no_project", "error": format!("the wizard finished but no new .PrjPcb appeared under {}", dir.display()), "steps": steps, "agentRestarted": start.get("success")}),+ (Err(e), _) => json!({"success": false, "errorCode": "wizard_failed", "error": e, "steps": steps, "agentRestarted": start.get("success")}),+ }+ }+ "" => json!({"success": false, "errorCode": "bad_args", "error": "format is required: eagle or kicad"}),+ o => json!({"success": false, "errorCode": "unsupported", "format": o, "formats": ["eagle", "kicad"], "error": format!("this bridge does not drive Altium's {o} importer yet"),- "_hint": "Altium's Import Wizard reads EAGLE, PADS, OrCAD, P-CAD, Allegro, xDxDesigner, CADSTAR and Zuken designs: a person can run it from File > Import Wizard. EAGLE is the next one the bridge will drive."}),+ "_hint": "Altium's Import Wizard also reads PADS, OrCAD, P-CAD, Allegro, xDxDesigner, CADSTAR and Zuken designs: a person can run it from File > Import Wizard."}),+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn an_eagle_design_is_its_sch_and_brd() {+ let d = std::env::temp_dir().join(format!("adom-eagle-{}", std::process::id()));+ std::fs::create_dir_all(&d).unwrap();+ std::fs::write(d.join("x.sch"), "<eagle/>").unwrap();+ std::fs::write(d.join("x.brd"), "<eagle/>").unwrap();+ let f = eagle_files(&d.join("x.brd").to_string_lossy());+ assert_eq!(f.len(), 2, "{f:?}");+ assert!(f[0].ends_with("x.sch"));+ let _ = std::fs::remove_dir_all(&d); } }
bridge-rs/src/verbs.rs+5−5@@ -457,11 +457,11 @@ fn describe() -> Value { json!({"installs": "[{edition, version, major, exe}]", "checked": "bool: whether an offer could be read (false today)", "offered": "the newer build on offer, or null", "why": "why offered is unknown", "unsaved": "[document] (apply)", "settings": "[{file, line}] (auto)"}), 60, "Read-only: nothing is opened or changed in Altium.", &["install", "readiness", "license_status"], &["Altium shows its updates on pages the bridge cannot read: the user updates Altium from inside it or with Altium's installer."], json!({"action": "check"})),- verb_doc("import_design", "Bring a foreign design into a new Altium project: kicad through Altium's KiCad importer. A format the bridge does not drive yet (EAGLE, PADS, OrCAD and the rest of Altium's Import Wizard) is refused by name.",- json!({"format": "kicad (required; eagle and the others are refused by name for now)", "filePath": "the design (required)", "timeout": "seconds, default 300"}),- json!({"format": "string", "result": "import_kicad's answer"}), 600,- "kicad answers as import_kicad. EAGLE is mapped and comes next; until then a person runs File > Import Wizard.",- &["import_kicad", "open_project", "project_info"], &["Altium's Import Wizard reads many formats; the bridge drives only KiCad's importer so far."], json!({"format": "kicad", "filePath": "C:/designs/board.kicad_pcb"})),+ verb_doc("import_design", "Bring a foreign design into a new Altium project: eagle through Altium's Import Wizard (the schematic and its board together), kicad through Altium's KiCad importer. A format the bridge does not drive yet is refused by name.",+ json!({"format": "eagle | kicad (required)", "filePath": "the design: an EAGLE .sch or .brd (its pair beside it comes too), or a KiCad file (required)", "outputDir": "where to look for the new project, default the source's folder", "timeout": "seconds (kicad), default 300"}),+ json!({"project": "the new .PrjPcb", "files": "[the files imported]", "steps": "[every wizard step and how it went]", "agentRestarted": "bool"}), 900,+ "The wizard runs outside the script engine with Altium's own import options. Its importer list takes a real click (it answers no UI Automation), so EAGLE briefly moves the pointer.",+ &["import_kicad", "open_project", "project_info"], &["Altium's Import Wizard also reads PADS, OrCAD, P-CAD, Allegro, xDxDesigner, CADSTAR and Zuken: those are refused by name until the bridge drives them."], json!({"format": "eagle", "filePath": "C:/designs/Board.sch"})), verb_doc("export_3d", "The board's 3D model in another format than STEP, by Altium's own exporter (File > Export): Parasolid (.x_t) or VRML (.wrl). step answers through export_step; a format Altium does not write is refused by name.", json!({"filePath": "the .PcbDoc (required)", "format": "parasolid | vrml | step (required; stl, obj, glb, 3mf, iges, ply and pdf3d are refused by name)", "output": "the file to write (default beside the board)", "outputDir": "folder, when output is not given", "timeout": "seconds to wait for the file, default 300"}), json!({"path": "the file", "bytes": "int", "format": "string", "exporter": "Altium's exporter", "exporterIndex": "its place on File > Export"}), 360,
src/bridge.json+1−1@@ -302,7 +302,7 @@ "launch": 240, "panelize": 240, "impedance": 120,- "current_capacity": 120, "plan_route": 300, "place_decoupling": 300, "plan_fanout": 300, "estimate_cost": 120, "simulate": 900, "export_spice": 900, "update_footprints_from_library": 600, "lint_library": 600, "export_pos": 120, "verb_times": 15, "prewarm": 120, "render_board": 300, "log_tail": 60, "sch_batch": 900, "import_step": 180, "edit_pours": 600, "export_3d": 360, "tool_update": 120, "import_design": 600,+ "current_capacity": 120, "plan_route": 300, "place_decoupling": 300, "plan_fanout": 300, "estimate_cost": 120, "simulate": 900, "export_spice": 900, "update_footprints_from_library": 600, "lint_library": 600, "export_pos": 120, "verb_times": 15, "prewarm": 120, "render_board": 300, "log_tail": 60, "sch_batch": 900, "import_step": 180, "edit_pours": 600, "export_3d": 360, "tool_update": 120, "import_design": 900, "height_check": 150, "copper_balance": 240, "return_path": 240,