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
altium-bridge 0.2.90: eleven new verbs, license never answers success for a press that didn't happen, update_pcb opens the project, sch_batch compares wires by path, export_3d waits out its Information box
13 files changed
+318−66
CHANGELOG.md+7−5bridge-rs/src/geom3d.rs+9−1bridge-rs/src/license.rs+118−17bridge-rs/src/main.rs+1−1bridge-rs/src/prefs.rs+68−16bridge-rs/src/sch.rs+8bridge-rs/src/schbatch.rs+80−11bridge-rs/src/verbs.rs+4−4dev-skills/altium-bridge-test/edit_drill.py+19−7package.json+1−1page.json+1−1src/BRIDGE_VERSION+1−1src/bridge.json+1−1CHANGELOG.md+7−5@@ -1,8 +1,6 @@ # Changelog -## 0.2.90 (unreleased)--Source only, not released. The unit tests pass and it builds, but the final shapes of these verbs have not run in Altium yet: an earlier build passed most of `edit_drill.py`, and the batteries, the drill's real-project steps and `license` `release` on Altium Designer are still to run.+## 0.2.90 - **Eleven verbs new in the standard** (EDA Bridge Standard #29, 0.30.14): - `altium_sch_no_connect`: No ERC markers at a point or on a pin, and removal by id.@@ -16,9 +14,13 @@ Source only, not released. The unit tests pass and it builds, but the final shap - `altium_select_items`: select parts by designator on a board or sheet, or clear, read back. - `altium_cancel_run`: stop the bridge's own long job between steps (`sch_batch` takes its ops back; `import_design`'s wizard closes with nothing imported). It never claims to interrupt Altium. - `altium_physical_properties`: refused with the reason. Altium keeps no material or mass on a part.-- **`altium_license` has a `release` action** (#29): gives the seat back through the licence page's Release button, and `released` says the page no longer shows a licence in use. Altium Designer only: Develop has no licence page the bridge can reach, so it is refused with that reason.-- **`altium_license` no longer answers success for a press that never happened.** An action now presses a button only when the licence page is showing (`licence_page_not_open` otherwise), and a click that failed answers `click_failed`. On Develop, `use_license` used to answer success, and its pixel fallback clicked the Home page instead.+- **`altium_license` has a `release` action** (#29): gives the seat back through the licence page's Release button, and `released` says the page no longer marks that licence In Use. It takes the first real licence by default, as an Altium can hold one and the free Viewer together; `product` names another. Altium Designer only: Develop has no licence page the bridge can reach, so it is refused with that reason.+- **`altium_license` no longer answers success for a press that never happened.** An action now presses a button only when the licence page is showing (`licence_page_not_open` otherwise), and a click that failed answers `click_failed`. On Develop, `use_license` used to answer success, and its pixel fallback clicked whatever document was in front instead.+- **`use_license` presses the right row and confirms it.** With nothing in use, it used to press the first button, the free Viewer's, instead of a real licence. It now prefers a real licence (`product` names another), answers from what the page marks In Use, and presses nothing when this Altium already holds a licence. - **`routing_state` and the board edits that read it take `filePath`** (`route_net`, `move_parts`, `place_vias`, `remove_items`, `ripup_nets` and others). They acted on the current board and ignored the argument, so naming a board that wasn't current was refused, or read and edited whichever board was in front. Found by the new edit drill.+- **`update_pcb` opens the project first.** With the board open on its own, Altium's change order never opened, and the verb said it found no differences even when its own preview listed parts to add. It now opens the project, and if the parts differ and no change order opens, it says that. Found by running it on a copy of Altium's own example.+- **`sch_batch` no longer answers `partial` when the sheet did come back.** Altium's Undo can leave an extra vertex on a straight wire or reorder items, which changed the sheet's fingerprint but nothing on the sheet. Wires now compare by the path they take. A real `partial` answer now has `differs`, naming what did not come back.+- **`export_3d` waits for Altium's closing Information box to go.** It pressed OK once and returned, and a box that outlasted the press refused the next verbs with `blocked_by_dialog`. - **`dev-skills/altium-bridge-test/edit_drill.py`:** runs the edit verbs the battery only dry-runs for real, on its own scratch board and sheet, and a second read confirms each. ## 0.2.89
bridge-rs/src/geom3d.rs+9−1@@ -203,7 +203,15 @@ fn run_exporter(out: &str, label: &str, known: u32, args: &Value) -> Value { } // the export ends on Altium's Information box ("export complete"): it is ours, so answer it, or the agent cannot // start again behind it (agentRestarted false, 2026-10-30); then the launcher ends- if let Some(i) = wait_dialog("Information", 15) { crate::dialogs::press(i, "OK"); }+ // press and see it go: the box can outlast one press, and left up it refuses every verb behind this one+ if let Some(mut i) = wait_dialog("Information", 15) {+ let t0 = std::time::Instant::now();+ loop {+ crate::dialogs::press(i, "OK");+ std::thread::sleep(Duration::from_millis(700));+ match wait_dialog("Information", 1) { Some(next) if t0.elapsed().as_secs() <= 10 => i = next, _ => break }+ }+ } crate::lifecycle::wait_helper_pub(&mut child, Duration::from_secs(60)); if size == 0 { return json!({"success": false, "errorCode": "not_written", "error": format!("{out} was not written"), "dialogs": crate::dialogs::scan()}); } json!({"success": true, "path": out, "bytes": size, "exporter": label, "exporterIndex": index, "windowEtiquette": "background",
bridge-rs/src/license.rs+118−17@@ -52,11 +52,43 @@ fn on_licence_page() -> bool { /// Pure: the title of Altium's window while its licence page is the document in front. pub fn title_is_licence_page(title: &str) -> bool { title.starts_with("License Management") } -/// Pure: has a find for the Release button come back with none? A failed find is not an answer.-pub fn release_button_gone(found: &Value) -> bool {- match found.get("matches").and_then(|m| m.as_array()) { Some(a) => a.is_empty(), None => found.get("errorCode").and_then(|c| c.as_str()) == Some("uia_not_found") }+/// The controls a find returns on the page, as (name, row height on screen).+fn page_rows(hwnd: i64, query: Value) -> Vec<(String, i64, i64)> {+ let mut args = query;+ args["hwnd"] = json!(hwnd);+ ab::call("desktop_find_controls", args, &[], 20).get("matches").and_then(|m| m.as_array()).cloned().unwrap_or_default().iter().map(|m| (+ m["name"].as_str().unwrap_or("").to_string(), m["rect"]["centerY"].as_i64().unwrap_or(0), m["nth"].as_i64().unwrap_or(0))).collect() } +/// The product on the row at this height: its name sits on the row, a little above or below the row's buttons. Pure.+pub fn product_on_row(y: i64, products: &[(String, i64, i64)]) -> Option<String> {+ products.iter().filter(|p| (p.1 - y).abs() <= 35).min_by_key(|p| (p.1 - y).abs()).map(|p| p.0.clone())+}++/// The products the page lists: "Altium ..." names on their own, not sentences that mention one.+fn page_products(hwnd: i64) -> Vec<(String, i64, i64)> {+ page_rows(hwnd, json!({"contains": "Altium"})).into_iter().filter(|p| p.0.starts_with("Altium Designer") && p.0.split_whitespace().count() <= 5).collect()+}++/// Every product the page marks In Use: an Altium can hold a real licence and the free Viewer together (measured+/// 2026-11-03), each row with its own In Use tag and Release button.+fn in_use_products(hwnd: i64) -> Vec<String> {+ let products = page_products(hwnd);+ page_rows(hwnd, json!({"automationId": "InUseTagText"})).iter().filter_map(|t| product_on_row(t.1, &products)).collect()+}++/// Which row a Release or Use License button press means: the product asked for, else the first real licence, else the+/// free Viewer, which is listed first and must not win just for that. (nth among the buttons, product). Pure.+pub fn pick_button(buttons: &[(String, i64, i64)], products: &[(String, i64, i64)], want: Option<&str>) -> Option<(i64, String)> {+ let rows: Vec<(i64, String)> = buttons.iter().filter_map(|b| product_on_row(b.1, products).map(|p| (b.2, p))).collect();+ if let Some(w) = want { let w = w.to_ascii_lowercase(); return rows.into_iter().find(|r| r.1.to_ascii_lowercase().contains(&w)); }+ rows.iter().find(|r| !is_viewer(&r.1)).cloned().or_else(|| rows.first().cloned())+}++/// Pure: is this the free Viewer, which runs no scripts?+pub fn is_viewer(product: &str) -> bool { product.to_ascii_lowercase().contains("viewer") }++ /// UIA first (quiet), image-space click only if UIA cannot reach the control. fn click_by_name_then_pixels(hwnd: i64, name: &str, automation_id: Option<&str>, pixel: impl FnOnce() -> Value) -> Value { let mut args = json!({"hwnd": hwnd, "name": name, "role": "button", "reason": "altium licence page: click the named button"});@@ -180,27 +212,79 @@ pub fn license(args: &Value) -> Value { out["_hint"] = json!("Altium Designer Develop has no way to its licence page the bridge can reach. altium_close releases the seat; starting Altium claims a free one."); return out; }+ let want = s_or(args, "product", "");+ let want = (!want.is_empty()).then_some(want); if action == "release" {- // no pixel fallback: Release is on every row in use, so only the button itself will do- let r = ab::call("desktop_ui_click", json!({"hwnd": hwnd, "automationId": "ReleaseButton", "name": "Release", "role": "button", "reason": "altium licence page: release the seat"}), &[], 30);+ // no pixel fallback: only the button on the right row will do. Confirmed by what the page then marks In Use; the+ // change can take a while (over 15 s, measured).+ let products = page_products(hwnd);+ let before = in_use_products(hwnd);+ let Some((nth, product)) = pick_button(&page_rows(hwnd, json!({"automationId": "ReleaseButton"})), &products, want.as_deref()) else {+ out["success"] = json!(false);+ out["errorCode"] = json!(if want.is_some() { "no_such_licence" } else { "no_licence_in_use" });+ out["error"] = json!(match &want { Some(w) => format!("no licence named {w} is in use"), None => "the page marks no licence In Use, so there is nothing to release".to_string() });+ out["inUse"] = json!(before);+ return out;+ };+ let r = ab::call("desktop_ui_click", json!({"hwnd": hwnd, "automationId": "ReleaseButton", "name": "Release", "role": "button", "nth": nth, "reason": "altium licence page: release the seat"}), &[], 30); let pressed = r.get("success").and_then(|b| b.as_bool()) != Some(false) && r.get("status").and_then(|s| s.as_str()) != Some("error");- let mut gone = false;+ let mut now = before.clone(); if pressed { let t0 = std::time::Instant::now();- while t0.elapsed() < Duration::from_secs(15) && !gone {- std::thread::sleep(Duration::from_secs(1));- gone = release_button_gone(&ab::call("desktop_find_controls", json!({"hwnd": hwnd, "automationId": "ReleaseButton"}), &[], 20));+ while t0.elapsed() < Duration::from_secs(45) && now.contains(&product) {+ std::thread::sleep(Duration::from_secs(2));+ now = in_use_products(hwnd); } }+ let released = pressed && !now.contains(&product); instance::invalidate_snapshot();- out["success"] = json!(pressed && gone);- out["released"] = json!(gone);+ out["success"] = json!(released);+ out["released"] = json!(released);+ out["product"] = json!(product);+ out["inUseBefore"] = json!(before);+ out["inUse"] = json!(now); out["clicked"] = json!({"action": action, "lane": "uia", "result": r}); out["licenceStateAfter"] = instance::licence_state().get("state").cloned().unwrap_or(Value::Null);- if !(pressed && gone) { out["errorCode"] = json!("release_failed"); out["error"] = json!(if pressed { "Release was pressed and the page still shows a licence in use" } else { "there is no Release button on the page: no licence is in use" }); }- out["_hint"] = json!("released says the page no longer shows a licence in use. Altium then stops running scripts, so the bridge's verbs answer not_licensed until altium_license {action:'use_license'} claims one again.");+ if !released { out["errorCode"] = json!("release_failed"); out["error"] = json!(if pressed { format!("Release was pressed on {product}, and the page still marks it In Use after 45 s") } else { "the Release button did not take the press".to_string() }); }+ out["_hint"] = json!("product is the licence released (by default the first real one; product: names another), inUse what the page marks now. On the free Viewer Altium runs no scripts, so the bridge's verbs answer not_licensed until altium_license {action:'use_license'} claims a licence again."); return out; }+ if action == "use_license" {+ let products = page_products(hwnd);+ let before = in_use_products(hwnd);+ // already holding a real licence, with none named: there is nothing to claim, and the Viewer's button is no answer+ if want.is_none() && before.iter().any(|p| !is_viewer(p)) {+ out["alreadyInUse"] = json!(true);+ out["inUse"] = json!(before);+ out["_hint"] = json!("This Altium already holds a licence: inUse names it. Nothing was pressed.");+ return out;+ }+ // the button on the right row, by UIA; when UIA sees no button, the pixel fallback below still has its say+ if let Some((nth, product)) = pick_button(&page_rows(hwnd, json!({"automationId": "UseLicenseButton"})), &products, want.as_deref()) {+ let r = ab::call("desktop_ui_click", json!({"hwnd": hwnd, "automationId": "UseLicenseButton", "name": "Use License", "role": "button", "nth": nth, "reason": "altium licence page: use this licence"}), &[], 30);+ let pressed = r.get("success").and_then(|b| b.as_bool()) != Some(false) && r.get("status").and_then(|s| s.as_str()) != Some("error");+ let mut now = before.clone();+ if pressed {+ let t0 = std::time::Instant::now();+ while t0.elapsed() < Duration::from_secs(30) && !now.contains(&product) {+ std::thread::sleep(Duration::from_secs(2));+ now = in_use_products(hwnd);+ }+ }+ let took = now.contains(&product);+ instance::invalidate_snapshot();+ out["success"] = json!(took);+ out["product"] = json!(product);+ out["inUse"] = json!(now);+ out["clicked"] = json!({"action": action, "lane": "uia", "result": r});+ out["windowEtiquette"] = json!("background");+ out["licenceStateAfter"] = instance::licence_state().get("state").cloned().unwrap_or(Value::Null);+ if !took { out["errorCode"] = json!("use_license_not_taken"); out["error"] = json!(format!("{product} was pressed, and the page does not mark it In Use after 30 s: its seats may be taken")); }+ out["_hint"] = json!("product is the licence pressed, inUse what the page marks now. product: names another row; by default the first that isn't the free Viewer.");+ return out;+ }+ if let Some(w) = want { out["success"] = json!(false); out["errorCode"] = json!("no_such_licence"); out["error"] = json!(format!("no Use License button on a licence named {w}")); out["products"] = json!(products.iter().map(|p| p.0.clone()).collect::<Vec<_>>()); return out; }+ } if let Some((x, y)) = page_coords(&action) { let sid = shot_id.clone(); let rect = instance::main_window().map(|w| instance::norm_rect(&w));@@ -417,10 +501,27 @@ mod page_tests { } #[test]- fn a_release_is_confirmed_by_the_button_going() {- assert!(release_button_gone(&json!({"matches": []})));- assert!(!release_button_gone(&json!({"matches": [{"name": "Release"}]})));- assert!(!release_button_gone(&json!({"error": "the relay dropped"})), "a failed find proves nothing");+ fn a_rows_product_is_the_name_on_that_row() {+ // measured on Altium Designer 26.11: names 16 px or so from their row's buttons, rows 115 px apart+ let p = |n: &str, y: i64, i: i64| (n.to_string(), y, i);+ let products = vec![p("Altium Designer Viewer", 659, 0), p("Altium Designer Develop", 775, 1)];+ assert_eq!(product_on_row(645, &products).as_deref(), Some("Altium Designer Viewer"));+ assert_eq!(product_on_row(762, &products).as_deref(), Some("Altium Designer Develop"));+ assert_eq!(product_on_row(300, &products), None);+ }++ #[test]+ fn use_license_prefers_a_real_licence_over_the_viewer() {+ let p = |n: &str, y: i64, i: i64| (n.to_string(), y, i);+ let products = vec![p("Altium Designer Viewer", 659, 0), p("Altium Designer Develop", 775, 1)];+ let both = vec![p("Use License", 645, 0), p("Use License", 762, 1)];+ assert_eq!(pick_button(&both, &products, None), Some((1, "Altium Designer Develop".to_string())), "the Viewer is listed first");+ assert_eq!(pick_button(&both, &products, Some("viewer")), Some((0, "Altium Designer Viewer".to_string())));+ assert_eq!(pick_button(&both[..1], &products, None), Some((0, "Altium Designer Viewer".to_string())), "the only one there is");+ assert_eq!(pick_button(&both, &products, Some("pro")), None);+ assert_eq!(pick_button(&[], &products, None), None);+ assert!(is_viewer("Altium Designer Viewer"));+ assert!(!is_viewer("Altium Designer Develop")); } #[test]
bridge-rs/src/main.rs+1−1@@ -79,7 +79,7 @@ use tiny_http::{Header, Method, Response, Server}; /// Attached to every failed reply (see the /command handler). const REPORT_ISSUES: &str = "If this looks like an altium-bridge BUG (not a refusal you expected), report it: check for a duplicate with `adom-wiki issue list adom/altium-bridge`, then `adom-wiki issue create adom/altium-bridge --title \"<verb>: <one-line symptom>\" --category bug-report --body \"<what you ran, what you expected, what happened, the VERBATIM response JSON (and errorShot if present), bridgeVersion, the Altium version from altium_status, the OS>\"`. A relay, routing, toast or lifecycle problem belongs on adom/adom-bridge instead. Reports from real machines are how this bridge gets correct: three different Altium builds behaved three different ways in one weekend."; -pub const BRIDGE_VERSION: &str = "0.2.89";+pub const BRIDGE_VERSION: &str = "0.2.90"; fn json_response(status: u16, body: &serde_json::Value) -> Response<std::io::Cursor<Vec<u8>>> { let data = serde_json::to_vec(body).unwrap_or_else(|_| b"{}".to_vec());
bridge-rs/src/prefs.rs+68−16@@ -152,20 +152,50 @@ pub fn extensions(args: &Value) -> Value { "_hint": "Altium's optional extensions on this machine, by edition (extensions is the first edition's). Installing and removing them happens on Altium's Extensions & Updates page, not through the bridge."}) } +/// How the saved document holds each named model: Altium writes `EMBED=TRUE|MODEL.NAME=x.step` in its body records (true+/// when the model is inside the document, false when it only points at a file), and EMBED=FALSE with no name for an+/// extruded body (measured on Altium's example boards, 2026-11-03). Pure.+pub fn embed_flags(doc: &[u8]) -> std::collections::BTreeMap<String, bool> {+ const KEY: &[u8] = b"EMBED=";+ let mut out = std::collections::BTreeMap::new();+ let mut i = 0;+ while i + KEY.len() < doc.len() {+ if !doc[i..].starts_with(KEY) { i += 1; continue; }+ let rest = &doc[i + KEY.len()..];+ let end = rest.iter().position(|b| *b == 0).unwrap_or(rest.len()).min(400);+ let text = String::from_utf8_lossy(&rest[..end]);+ let mut f = text.split('|');+ let flag = f.next().unwrap_or("").eq_ignore_ascii_case("TRUE");+ if let Some(name) = f.next().and_then(|x| x.strip_prefix("MODEL.NAME=")).filter(|n| !n.is_empty()) {+ // inside the document wins if a name is recorded both ways+ let e = out.entry(name.to_string()).or_insert(flag);+ *e = *e || flag;+ }+ i += KEY.len() + end;+ }+ out+}++/// Can this name be looked up on disk at all? Altium usually records a bare file name. Pure.+fn is_full_path(f: &str) -> bool { f.contains(":\\") || f.contains(":/") || f.starts_with("\\\\") || f.starts_with('/') }+ /// What one part's models say: the row is the agent's [ref, footprint, [[file, overall, standoff, w, h]]], `to_mm` turns-/// raw units to mm, and `found` says whether a named file is on disk. A model sits inside the Altium document, so it is-/// there whether or not the file it came from still is; that file is reported beside it. Pure.-pub fn check_part(row: &Value, to_mm: f64, found: &dyn Fn(&str) -> bool) -> Value {+/// raw units to mm, `embedded` says how the saved document holds a named model, and `on_disk` whether a file exists. A+/// model embedded in the document is there whether or not the file it came from still is. Pure.+pub fn check_part(row: &Value, to_mm: f64, embedded: &dyn Fn(&str) -> Option<bool>, on_disk: &dyn Fn(&str) -> bool) -> Value { let models: Vec<Value> = row[2].as_array().cloned().unwrap_or_default().iter().map(|b| { let file = b[0].as_str().unwrap_or(""); let n = |i: usize| b[i].as_f64().unwrap_or(0.0) * to_mm; let (h, s) = (n(1), n(2)); let geometry = h > s && n(3) > 0.0 && n(4) > 0.0;- json!({"path": if file.is_empty() { Value::Null } else { json!(file) }, "location": "embedded", "found": true, "hasGeometry": geometry,- "kind": if file.is_empty() { "extruded" } else { "model" }, "sourceFileFound": if file.is_empty() { Value::Null } else { json!(found(file)) }, "heightMm": ((h - s) * 1000.0).round() / 1000.0})+ let linked = !file.is_empty() && embedded(file) == Some(false);+ let source = if is_full_path(file) { json!(on_disk(file)) } else { Value::Null };+ json!({"path": if file.is_empty() { Value::Null } else { json!(file) }, "location": if linked { "file" } else { "embedded" }, "found": if linked { on_disk(file) } else { true }, "hasGeometry": geometry,+ "kind": if file.is_empty() { "extruded" } else { "model" }, "sourceFileFound": source, "heightMm": ((h - s) * 1000.0).round() / 1000.0}) }).collect(); let mut issues = Vec::new(); if models.is_empty() { issues.push("no 3D model".to_string()); }+ if models.iter().any(|m| m["found"] != json!(true)) { issues.push("a linked model's file is not found".to_string()); } if models.iter().any(|m| m["hasGeometry"] != json!(true)) { issues.push("a model holds no geometry".to_string()); } json!({"name": row[0], "footprint": row[1], "models": models, "issues": issues}) }@@ -181,13 +211,19 @@ pub fn model_check(args: &Value) -> Value { let mut want: Vec<String> = args.get("refs").and_then(|v| v.as_array()).cloned().unwrap_or_default().iter().filter_map(|x| x.as_str().map(str::to_ascii_lowercase)).collect(); if let Some(f) = crate::support::s(args, "footprint") { want.push(f.to_ascii_lowercase()); } let to_mm = 0.0254 / 10000.0;- let found = |f: &str| std::path::Path::new(f).is_file();+ // how the document holds its models is in the saved file; a model added since the last save reads as embedded, as+ // Altium adds them. A linked model named without a folder is looked for beside the document.+ let doc_path = d["document"].as_str().unwrap_or("").to_string();+ let flags = std::fs::read(&doc_path).map(|b| embed_flags(&b)).unwrap_or_default();+ let embedded = |f: &str| flags.get(f).copied();+ let on_disk = |f: &str| std::path::Path::new(f).is_file() || std::path::Path::new(&doc_path).parent().map(|p| p.join(f).is_file()).unwrap_or(false); let parts: Vec<Value> = d["parts"].as_array().cloned().unwrap_or_default().iter() .filter(|p| want.is_empty() || p[0].as_str().map(|x| want.contains(&x.to_ascii_lowercase())).unwrap_or(false))- .map(|p| check_part(p, to_mm, &found)).collect();+ .map(|p| check_part(p, to_mm, &embedded, &on_disk)).collect(); if !want.is_empty() && parts.is_empty() { return json!({"success": false, "errorCode": "not_found", "error": format!("none of {want:?} is on this document"), "document": d["document"]}); } let names = |f: &dyn Fn(&Value) -> bool| parts.iter().filter(|p| f(p)).filter_map(|p| p["name"].as_str().map(str::to_string)).collect::<Vec<_>>(); let no_model = names(&|p| p["models"].as_array().map(|b| b.is_empty()).unwrap_or(true));+ let not_found = names(&|p| p["models"].as_array().map(|b| b.iter().any(|x| x["found"] != json!(true))).unwrap_or(false)); let no_geometry = names(&|p| p["models"].as_array().map(|b| !b.is_empty() && b.iter().any(|x| x["hasGeometry"] != json!(true))).unwrap_or(false)); let lost_source = names(&|p| p["models"].as_array().map(|b| b.iter().any(|x| x["sourceFileFound"] == json!(false))).unwrap_or(false)); // the report is capped, the answer is not: ok and checked speak for every part, with the worst ones listed first@@ -195,8 +231,8 @@ pub fn model_check(args: &Value) -> Value { let mut shown = parts.clone(); shown.sort_by_key(|p| p["issues"].as_array().map(|i| i.is_empty()).unwrap_or(true)); shown.truncate(limit);- json!({"success": true, "ok": no_model.is_empty() && no_geometry.is_empty(), "kind": d["kind"], "document": d["document"], "checked": parts.len(), "parts": shown, "noModel": no_model, "noGeometry": no_geometry, "sourceFileMissing": lost_source,- "_hint": "Altium keeps a part's 3D model inside the document, so a model still draws when its source file has gone: sourceFileMissing is for information, and an update from that file would fail. ok and checked cover every part; parts lists up to limit, those with issues first. altium_bodies says whether each body sits where the board puts the part."})+ json!({"success": true, "ok": no_model.is_empty() && no_geometry.is_empty() && not_found.is_empty(), "kind": d["kind"], "document": d["document"], "checked": parts.len(), "parts": shown, "noModel": no_model, "noGeometry": no_geometry, "notFound": not_found, "sourceFileMissing": lost_source,+ "_hint": "location is how the saved document holds each model: embedded models are inside it and draw whether or not their source file exists; a linked one (file) needs its file, and notFound names the parts whose file is gone. sourceFileFound is null when Altium recorded only a file name, which can't be looked up. noModel has no body at all; noGeometry has a body with no height or size. ok and checked cover every part; parts lists up to limit, those with issues first. altium_bodies says whether each body sits where the board puts the part."}) } #[cfg(test)]@@ -208,18 +244,34 @@ mod tests { let k = 10000.0 / 0.0254; let to_mm = 1.0 / k; let raw = |mm: f64| mm * k;- let row = json!(["U1", "QFN", [["C:/m/u1.step", raw(1.0), 0.0, raw(4.0), raw(4.0)], ["", raw(0.5), 0.0, raw(2.0), raw(2.0)]]]);- let r = check_part(&row, to_mm, &|_| false);+ let row = json!(["U1", "QFN", [["CAPC0603X03L.step", raw(1.0), 0.0, raw(4.0), raw(4.0)], ["", raw(0.5), 0.0, raw(2.0), raw(2.0)]]]);+ let r = check_part(&row, to_mm, &|_| Some(true), &|_| false); assert_eq!(r["name"], "U1");- assert_eq!(r["issues"], json!([]), "a lost source file is not an issue: the model is in the document");+ assert_eq!(r["issues"], json!([]), "an embedded model needs no file"); assert_eq!(r["models"][0]["location"], "embedded"); assert_eq!(r["models"][0]["found"], true);- assert_eq!(r["models"][0]["sourceFileFound"], false);+ assert_eq!(r["models"][0]["sourceFileFound"], Value::Null, "a bare name can't be looked up"); assert_eq!(r["models"][0]["heightMm"], 1.0); assert_eq!(r["models"][1]["kind"], "extruded");- assert_eq!(r["models"][1]["sourceFileFound"], Value::Null);- assert_eq!(check_part(&json!(["R1", "R", []]), to_mm, &|_| true)["issues"], json!(["no 3D model"]));- assert_eq!(check_part(&json!(["R1", "R", [["x.step", 0.0, 0.0, 0.0, 0.0]]]), to_mm, &|_| true)["models"][0]["hasGeometry"], false);+ // a model that only points at a file needs that file+ let linked = json!(["U2", "QFN", [["C:/m/u2.step", raw(1.0), 0.0, raw(4.0), raw(4.0)]]]);+ let gone = check_part(&linked, to_mm, &|_| Some(false), &|_| false);+ assert_eq!(gone["models"][0]["location"], "file");+ assert_eq!(gone["models"][0]["found"], false);+ assert_eq!(gone["models"][0]["sourceFileFound"], false);+ assert_eq!(gone["issues"], json!(["a linked model's file is not found"]));+ assert_eq!(check_part(&linked, to_mm, &|_| Some(false), &|_| true)["issues"], json!([]));+ assert_eq!(check_part(&json!(["R1", "R", []]), to_mm, &|_| None, &|_| true)["issues"], json!(["no 3D model"]));+ assert_eq!(check_part(&json!(["R1", "R", [["x.step", 0.0, 0.0, 0.0, 0.0]]]), to_mm, &|_| None, &|_| true)["models"][0]["hasGeometry"], false);+ }++ #[test]+ fn the_saved_file_says_how_a_model_is_held() {+ let doc = b"xx\0EMBED=TRUE|MODEL.NAME=a.step|MODEL.2D.X=1mil\0yy\0EMBED=FALSE|MODEL.NAME=|MODEL.MODELTYPE=0\0EMBED=FALSE|MODEL.NAME=b.step|Z=1\0";+ let f = embed_flags(doc);+ assert_eq!(f.get("a.step"), Some(&true));+ assert_eq!(f.get("b.step"), Some(&false));+ assert_eq!(f.len(), 2, "an extruded body names no model"); } #[test]
bridge-rs/src/sch.rs+8@@ -316,6 +316,8 @@ pub fn update_pcb(args: &Value) -> Value { } // from the board, Import Changes (Action=UpdateMe) is the change order; from a sheet, Action=UpdateOther // opened nothing on AD 26.11.1 (2026-10-21)+ // the change order belongs to the project: a board open on its own has none, and Compare then opens nothing+ if let Some(e) = support::must_open(&prj, 60) { return e; } if let Some(e) = support::must_open(&board, 60) { return e; } agent::call("run_process", &[("process", "WorkspaceManager:Compare".into()), ("params", "ObjectKind=Project|Action=UpdateMe".into())], None, Duration::from_secs(6)); let find = |needle: &str| -> Option<Value> {@@ -359,6 +361,12 @@ pub fn update_pcb(args: &Value) -> Value { let Some(eco) = eco else { let dl = crate::dialogs::scan_scoped(true); let boxed = steps.iter().any(|s| s.get("dialog").is_some());+ // the parts differ, so "no differences" can't be the reason+ if !add.is_empty() || !remove.is_empty() {+ return json!({"success": false, "errorCode": "eco_dialog_not_found", "executed": false, "preview": preview, "steps": steps, "dialogs": dl, "elapsedSec": support::elapsed_round(t0),+ "error": "the sheets and the board differ, but Altium opened no change order",+ "_hint": "preview lists the parts that differ. Open the project with altium_open_project and check the board belongs to it (altium_project_info), then try again."});+ } return json!({"success": boxed, "errorCode": if boxed { Value::Null } else { json!("eco_dialog_not_found") }, "executed": false, "preview": preview, "steps": steps, "dialogs": dl, "elapsedSec": support::elapsed_round(t0), "_hint": "No Engineering Change Order opened: Altium found no differences between the sheets and the board that its change order carries. Parts, nets and parameters are carried. If you expected changes, check the sheets are saved and that no second project with the same file names is open."});
bridge-rs/src/schbatch.rs+80−11@@ -4,6 +4,7 @@ //! sheet's fingerprint (its parts and wiring) must match the one taken before the batch. If it does not, the batch //! answers partial with the ops that ran, as the standard allows for a tool that cannot take a batch back. use serde_json::{json, Value};+use std::collections::BTreeMap; use std::time::Duration; /// The schematic verbs a batch may run: they each edit one sheet, named by `sheet`, and leave it unsaved.@@ -37,18 +38,57 @@ pub fn plan(ops: &[Value], sheet: &str, project: Option<&str>) -> Result<Vec<(St Ok(out) } -/// The sheet's fingerprint: its parts (designator, symbol, place, turn, parameters) and wiring items, ids included.-fn fingerprint(sheet: &str) -> Option<String> {+/// The sheet's fingerprint, by what it holds: its parts (designator, symbol, place, turn, parameters) and each kind of+/// wiring item, ids included. None when the sheet could not be read.+fn fingerprint(sheet: &str) -> Option<BTreeMap<String, String>> { let parts = crate::verbs::dispatch("schematic_data", &json!({"filePath": sheet}), &[]); let items = crate::verbs::dispatch("sch_items", &json!({"sheet": sheet}), &[]);- if items.get("success").and_then(|b| b.as_bool()) == Some(false) { return None; }+ if items.get("success").and_then(|b| b.as_bool()) == Some(false) || parts.get("success").and_then(|b| b.as_bool()) == Some(false) { return None; } let comps: Vec<Value> = parts.get("data").and_then(|d| d["components"].as_array()).or(parts["components"].as_array()).cloned().unwrap_or_default().iter() .map(|c| json!([c["designator"], c["libReference"], c["xMil"], c["yMil"], c["orientation"], c["params"]])).collect();- let mut wiring = items.clone();- if let Some(m) = wiring.as_object_mut() { m.retain(|k, _| matches!(k.as_str(), "wires" | "buses" | "busEntries" | "labels" | "powerPorts" | "junctions" | "noConnects" | "texts" | "sheets")); }- Some(crate::routing::fnv(&json!([comps, wiring]).to_string()))+ let mut out = BTreeMap::new();+ out.insert("parts".to_string(), crate::routing::fnv(&json!(comps).to_string()));+ // as sets: Undo can put a sheet's items back in another order, which changes nothing on the sheet. Wires and buses+ // by the path they take: Undo can also leave an extra vertex on a straight run (measured 2026-11-03), which changes+ // the wire's id and nothing else.+ for k in ["wires", "buses"] {+ let paths: Vec<Value> = items[k].as_array().cloned().unwrap_or_default().iter().map(wire_path).collect();+ out.insert(k.to_string(), crate::routing::fnv(&as_set(&json!(paths))));+ }+ for k in ["busEntries", "labels", "powerPorts", "junctions", "noConnects", "texts", "sheets"] { out.insert(k.to_string(), crate::routing::fnv(&as_set(&items[k]))); }+ Some(out)+}++/// The path a wire takes: its corners only, the same whichever end it was drawn from. Pure.+pub fn wire_path(w: &Value) -> Value {+ let pts: Vec<(f64, f64)> = w["points"].as_array().cloned().unwrap_or_default().iter().filter_map(|p| Some((p.get(0)?.as_f64()?, p.get(1)?.as_f64()?))).collect();+ let mut out: Vec<(f64, f64)> = Vec::new();+ for p in pts {+ if out.last() == Some(&p) { continue; }+ // a vertex between two legs on one straight line is no corner+ if out.len() >= 2 {+ let (a, b) = (out[out.len() - 2], out[out.len() - 1]);+ let cross = (b.0 - a.0) * (p.1 - b.1) - (b.1 - a.1) * (p.0 - b.0);+ let onward = (b.0 - a.0) * (p.0 - b.0) + (b.1 - a.1) * (p.1 - b.1);+ if cross.abs() < 1e-6 && onward > 0.0 { out.pop(); }+ }+ out.push(p);+ }+ let back: Vec<(f64, f64)> = out.iter().rev().cloned().collect();+ let key = |v: &[(f64, f64)]| v.iter().map(|p| format!("{:.4},{:.4}", p.0, p.1)).collect::<Vec<_>>().join(" ");+ json!(key(&out).min(key(&back)))+}++/// A list's rows in an order of their own, so two lists holding the same rows read the same. Pure.+pub fn as_set(list: &Value) -> String {+ let mut rows: Vec<String> = list.as_array().map(|a| a.iter().map(|x| x.to_string()).collect()).unwrap_or_default();+ rows.sort();+ rows.join("\n") } +/// What differs between two fingerprints. Pure.+pub fn differs(a: &BTreeMap<String, String>, b: &BTreeMap<String, String>) -> Vec<String> { a.iter().filter(|(k, v)| b.get(*k) != Some(*v)).map(|(k, _)| k.clone()).collect() }+ /// Compile the project and count the Messages for this sheet by class. fn erc_counts(project: &str, sheet: &str) -> Value { let r = crate::outputs::compile(&json!({"projectPath": project, "limit": 2000}));@@ -109,18 +149,23 @@ pub fn sch_batch(args: &Value) -> Value { for _ in 0..applied { crate::agent::call("run_process", &[("process", "Sch:Undo".into()), ("params", "".into())], None, Duration::from_secs(30)); }- let back = fingerprint(&sheet);- let restored = back.as_deref() == Some(before.as_str());+ // a read that fails or lands while Altium is still settling is not proof the sheet differs: PARTIAL is a strong+ // thing to tell a caller, so look again before saying it+ let (mut restored, mut left) = (false, vec!["unread".to_string()]);+ for attempt in 0..4 {+ if attempt > 0 { std::thread::sleep(Duration::from_millis(1500)); }+ if let Some(now) = fingerprint(&sheet) { left = differs(&before, &now); if left.is_empty() { restored = true; break; } }+ } let mut out = json!({"success": false, "errorCode": if !restored { "partial" } else if stop { "cancelled" } else { "op_failed" }, "failedOp": i, "op": name, "error": r.get("error").cloned().unwrap_or(json!("the op failed")), "reply": r, "results": results,- "mutated": !restored, "undone": applied, "restored": restored});+ "mutated": !restored, "undone": applied, "restored": restored, "differs": left}); out["_hint"] = json!(if restored { "The batch was taken back: the sheet is as it was before it. Fix failedOp and run the batch again." }- else { "PARTIAL: the ops in results ran and Undo did not bring the sheet back to where it was. Read it (schematic_data, sch_items) before going on; Altium's Edit > Undo can step further back by hand." });+ else { "PARTIAL: the ops in results ran and Undo did not bring the sheet back to where it was: differs names what is not as it was. Read it (schematic_data, sch_items) before going on; Altium's Edit > Undo can step further back by hand." }); return out; } let after = fingerprint(&sheet); let erc_after = if erc { erc_counts(project.as_deref().unwrap_or(""), &sheet) } else { Value::Null };- json!({"success": true, "results": results, "mutated": after.as_deref() != Some(before.as_str()), "ercBefore": erc_before, "ercAfter": erc_after,+ json!({"success": true, "results": results, "mutated": after.as_ref() != Some(&before), "ercBefore": erc_before, "ercAfter": erc_after, "undoSteps": steps.len(), "_hint": "Applied in order on the open sheet, unsaved: altium_save {filePath} keeps it. Each op is one of Altium's undo steps (undoSteps). ercBefore and ercAfter are the sheet's Messages by class from a compile before and after (erc:false skips both)."}) }@@ -129,6 +174,30 @@ pub fn sch_batch(args: &Value) -> Value { mod tests { use super::*; + #[test]+ fn a_wire_is_the_path_it_takes() {+ let w = |p: Value| wire_path(&json!({"id": "x", "points": p}));+ assert_eq!(w(json!([[0.0, 0.0], [2.5, 0.0], [5.0, 0.0]])), w(json!([[0.0, 0.0], [5.0, 0.0]])), "a vertex on a straight run");+ assert_eq!(w(json!([[0.0, 0.0], [5.0, 0.0]])), w(json!([[5.0, 0.0], [0.0, 0.0]])), "either way round");+ assert_ne!(w(json!([[0.0, 0.0], [5.0, 0.0]])), w(json!([[0.0, 0.0], [5.0, 1.0]])), "moved");+ assert_ne!(w(json!([[0.0, 0.0], [5.0, 0.0], [5.0, 5.0]])), w(json!([[0.0, 0.0], [5.0, 5.0]])), "a real corner");+ assert_ne!(w(json!([[0.0, 0.0], [5.0, 0.0], [2.0, 0.0]])), w(json!([[0.0, 0.0], [2.0, 0.0]])), "doubling back is not straight on");+ }++ #[test]+ fn order_on_the_sheet_means_nothing() {+ assert_eq!(as_set(&json!([{"id": "a"}, {"id": "b"}])), as_set(&json!([{"id": "b"}, {"id": "a"}])));+ assert_ne!(as_set(&json!([{"id": "a"}, {"id": "b"}])), as_set(&json!([{"id": "a"}, {"id": "c"}])));+ assert_ne!(as_set(&json!([{"id": "a"}])), as_set(&json!([{"id": "a"}, {"id": "a"}])), "two of the same is not one");+ }++ #[test]+ fn a_fingerprint_says_what_differs() {+ let m = |v: &[(&str, &str)]| v.iter().map(|(a, b)| (a.to_string(), b.to_string())).collect::<BTreeMap<_, _>>();+ assert!(differs(&m(&[("wires", "1"), ("parts", "2")]), &m(&[("wires", "1"), ("parts", "2")])).is_empty());+ assert_eq!(differs(&m(&[("wires", "1"), ("parts", "2")]), &m(&[("wires", "9"), ("parts", "2")])), ["wires"]);+ }+ #[test] fn a_plan_fills_the_sheet_and_refuses_what_it_cannot_take_back() { let ops = vec![json!({"op": "sch_place_part", "libReference": "RES"}), json!({"op": "altium_sch_connect_pins", "pairs": [{"from": "R9.1", "to": "U1.3"}]})];
bridge-rs/src/verbs.rs+4−4@@ -186,8 +186,8 @@ fn describe() -> Value { &["The caller owns the VOICE (adom-tts) - the bridge never synthesizes speech.", "After done:true, restore the user's own document (altium_activate_document)."], json!({"live": true, "stage": 0})),- verb_doc("license", "Drive the License Management page (UIA first - no cursor, no foreground).", json!({"action": "show|refresh|use_license|release|start_trial|sign_out"}), shot.clone(), 60,- "One On-Demand seat serves EVERY Altium app on this machine. use_license claims a free seat; release gives it back and released says the page confirms it. Altium then stops running scripts, so the bridge's verbs answer not_licensed until it is claimed again.",+ verb_doc("license", "Drive the License Management page (UIA first - no cursor, no foreground).", json!({"action": "show|refresh|use_license|release|start_trial|sign_out", "product": "use_license, release: part of the licence's name (default the first that isn't the free Viewer)"}), shot.clone(), 90,+ "One On-Demand seat serves EVERY Altium app on this machine. use_license claims a free seat, and inUse says what the page then marks In Use. release gives it back, and released says the page confirms it. Altium falls back to Viewer and stops running scripts, so the bridge's verbs answer not_licensed until a licence is claimed again.", &["ensure_licensed", "license_status", "close"], &["NEVER kill an Altium holding the seat: the lease strands, the page shows Seats 0/1 while every claim fails. altium_close releases it.", "Altium Designer Develop has no licence page the bridge can reach: every action but show and refresh answers licence_page_not_open. altium_close releases its seat."], json!({"action": "use_license"})), verb_doc("close", "Polite close (releases the licence seat). Frees a script engine parked on a breakpoint first (Altium refuses to close over one). discardChanges:true answers Altium's save prompts with Save None for callers whose modified documents are ALL their own; force needs acceptSeatLoss.", json!({"discardChanges": "bool, default false: press Save None + confirm on 'Confirm Save Locally'", "waitSec": "float, default 20", "force": "bool", "acceptSeatLoss": "bool", "instance": "pid, when several Altiums run"}), json!({"closedInSec": "float", "engineFreed": "object|null", "stuckModalOrphan": "{pid,tid,hwnd} when Altium was wedged in a modal loop and the bridge ended it gracefully", "errorCode": "unsaved_changes | close_blocked_by_dialog | altium_modal_orphan | modal_orphan_survived_quit | close_timeout"}), 120, "A save prompt on close NAMES the documents - read it; on a shared machine one may belong to another AI thread. Never defaulted.",@@ -499,8 +499,8 @@ fn describe() -> Value { "On a board with a schematic, parts normally arrive through update_pcb. The board is left unsaved: altium_save keeps it.", &["move_parts", "edit_parts", "remove_parts", "update_pcb", "routing_state"], &["A net in nets must already exist on the board.", "A footprint missing from the library places nothing from that library."], json!({"filePath": "C:/proj/Board.PcbDoc", "parts": [{"library": "C:/proj/Parts.PcbLib", "ref": "R9", "footprint": "R0603", "x": 12.0, "y": 8.0, "rotation": 90}]})), verb_doc("model_check", "Per part of a board or footprint of a library: does it have a 3D model, where the model is, whether its source file is still found, and whether it holds any geometry. Whether a body sits in the right place is bodies'.", json!({"filePath": "a board: every part on it", "library": "a footprint library (with footprint)", "footprint": "one footprint's name", "refs": "[ref] (default all)", "limit": "int, default 50: parts reported"}),- json!({"parts": "[{name, footprint, models: [{path, location, found, hasGeometry, kind: model|extruded, sourceFileFound, heightMm}], issues: [string]}]", "checked": "int", "ok": "bool: every part has a model that is found and holds geometry", "noModel": "[name]", "noGeometry": "[name]", "sourceFileMissing": "[name]", "kind": "board | library"}), 180,- "Read only. Altium keeps the model inside the document, so a model still draws after its source file has gone.", &["bodies", "lint_library", "add_body", "height_check"], &["sourceFileFound looks on this machine, at the name the model was loaded from."], json!({"filePath": "C:/proj/Board.PcbDoc"})),+ json!({"parts": "[{name, footprint, models: [{path, location, found, hasGeometry, kind: model|extruded, sourceFileFound, heightMm}], issues: [string]}]", "checked": "int", "ok": "bool: every part has a model that is found and holds geometry", "noModel": "[name]", "noGeometry": "[name]", "notFound": "[name]: a linked model's file is gone", "sourceFileMissing": "[name]", "kind": "board | library"}), 180,+ "Read only. location comes from the saved document: an embedded model draws without its source file, a linked one needs it.", &["bodies", "lint_library", "add_body", "height_check"], &["sourceFileFound is null when Altium recorded only a file name.", "A model added since the last save reads as embedded until the document is saved."], json!({"filePath": "C:/proj/Board.PcbDoc"})), 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)", "boardPath": "the EAGLE board, when its name differs from the schematic's", "name": "rename the new project", "outputDir": "the folder the new project goes in, default the source's folder", "timeout": "seconds (kicad), default 300"}), json!({"design": "the new .PrjPcb", "project": "the same", "parts": "int", "nets": "int", "warnings": "[what the importer's log says it could not read]", "check": "{imported, source, matchesSource, unconnected}: the board against the EAGLE file", "files": "[the files imported]", "steps": "[every wizard step and how it went]", "agentRestarted": "bool"}), 900,
dev-skills/altium-bridge-test/edit_drill.py+19−7@@ -231,14 +231,16 @@ def main(): step("sch_reset_fields", sch_reset_fields) def sch_update_from_library():- # change the library's symbol, then the placed parts must take it- params = lambda: json.dumps([c.get("params") for c in (call("schematic_data", {"filePath": S}).get("data") or {}).get("components", []) if c.get("designator") == "U1"])+ # change the library's symbol: an update compares pins, so the part is named to re-place it, and the placed part+ # must take the change+ params = lambda: json.dumps([c.get("params") for c in (call("schematic_data", {"filePath": S, "params": True}).get("data") or {}).get("components", []) if c.get("designator") == "U1"]) before = params() call("set_params", {"libraryPath": SL, "symbolName": "TST_SOIC8", "params": {"DrillParam": "drilled"}}) call("save", {"filePath": SL})- r = call("sch_update_from_library", {"sheet": S})+ plain = call("sch_update_from_library", {"sheet": S})+ r = call("sch_update_from_library", {"sheet": S, "symbols": ["TST_SOIC8"]}) after = params()- return r.get("success") and "drilled" not in before and "drilled" in after, f"U1 params {after[:160]}: updated {r.get('updated')} {r.get('error')}"+ return r.get("success") and any(c.get("ref") == "U1" for c in plain.get("unchanged") or []) and "DrillParam" not in before and "drilled" in after, f"same pins read unchanged; named, U1 params {after[:170]}: {r.get('error')}" step("sch_update_from_library", sch_update_from_library) def cancel_run():@@ -246,6 +248,8 @@ def main(): import threading y = row() w0 = n("wires")+ keep = lambda: [(x.get("from"), x.get("to"), x.get("points")) for x in items().get("wires") or []]+ k0 = keep() ops = [{"op": "sch_wire", "points": [[20.32 + i * 2.54, y], [20.32 + i * 2.54, y - 2.54]]} for i in range(30)] box = {} t = threading.Thread(target=lambda: box.update(call("sch_batch", {"filePath": S, "ops": ops, "erc": False}, timeout=500)))@@ -257,7 +261,7 @@ def main(): if got.get("cancelRequested"): break t.join()- return got.get("cancelRequested") and box.get("errorCode") == "cancelled" and box.get("restored") is True and n("wires") == w0, f"asked at stage {got.get('stage')}; batch answered {box.get('errorCode')}, undone {box.get('undone')}, restored {box.get('restored')}, wires {w0} -> {n('wires')}"+ return got.get("cancelRequested") and box.get("errorCode") == "cancelled" and box.get("restored") is True and n("wires") == w0, f"asked at stage {got.get('stage')}; batch answered {box.get('errorCode')}, undone {box.get('undone')}, restored {box.get('restored')}, differs {box.get('differs')}, wires {w0} -> {n('wires')}, row y {y}, came back {[x for x in keep() if x not in k0][:3]}, lost {[x for x in k0 if x not in keep()][:3]}" step("cancel_run", cancel_run) # -- board ----------------------------------------------------------------------------------------------------@@ -433,6 +437,13 @@ def main(): step("foreign:place_parts", f_place_parts) def f_model_check():+ # a board with real embedded STEP models too, not only extruded bodies+ f2 = shell(f'cmd /c xcopy /E /I /Y /Q "{examples.format("ADDevelop").replace("SpiritLevel-SL1", "Mini PC")}\\Mini PC - WiFi" "{dw}\\foreign-wifi" >nul & dir /s /b "{dw}\\foreign-wifi\\WiFi.PcbDoc"').strip().replace("\\", "/")+ m = call("model_check", {"filePath": f2, "limit": 500})+ real = [x for p in m.get("parts") or [] for x in p["models"] if x["kind"] == "model"]+ if not real or not all(x["location"] == "embedded" and x["found"] and x["sourceFileFound"] is None for x in real) or m.get("sourceFileMissing"):+ return False, f"WiFi.PcbDoc read {json.dumps(real[:1])[:200]}, sourceFileMissing {(m.get('sourceFileMissing') or [])[:3]}: {m.get('error')}"+ call("close_all_documents", {"save": True}) r = call("model_check", {"filePath": FB, "limit": 500}) withb = [p for p in r.get("parts") or [] if p.get("models")] return r.get("success") and r.get("checked") == len(first) and len(withb) > 0, f"{r.get('checked')} parts checked, {len(withb)} with bodies, noModel {len(r.get('noModel') or [])}, kinds {sorted({b['kind'] for p in withb for b in p['models']})}, sample {json.dumps(withb[0]['models'][0])[:120] if withb else ''}"@@ -477,11 +488,12 @@ def main(): n0 = set(fcomps()) r = call("sch_place_part", {"sheet": FSH, "library": FS, "symbol": sym, "designator": "DRILL7", "x": 300, "y": 300}) call("save", {"filePath": FSH})- u = call("update_pcb", {"projectPath": FP, "execute": True}, timeout=400)+ # Altium's example has parts on one side only (Logo5 on the board alone), so this copy takes the removal too+ u = call("update_pcb", {"projectPath": FP, "execute": True, "allowRemovals": True}, timeout=400) n1 = fcomps() new = sorted(set(n1) - n0) part = n1.get("DRILL7") or {}- return r.get("success") and new == ["DRILL7"] and part.get("pattern"), f"{sym}: new on the board {new}, footprint {part.get('pattern')}: place {r.get('error')} update {json.dumps({k: u.get(k) for k in ('success', 'error', 'errorCode', 'added', 'applied')})[:160]}"+ return r.get("success") and "DRILL7" in new and part.get("pattern"), f"{sym}: new on the board {new}, footprint {part.get('pattern')}: place {r.get('error')} update {json.dumps({k: u.get(k) for k in ('success', 'error', 'errorCode', 'added', 'applied')})[:160]}" step("foreign:update_pcb", f_update_pcb) call("save", {"filePath": FB})
package.json+1−1@@ -1,6 +1,6 @@ { "slug": "altium-bridge",- "version": "0.2.89",+ "version": "0.2.90", "type": "app", "description": "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.", "tags": [
page.json+1−1@@ -4,7 +4,7 @@ "type": "app", "title": "Altium Bridge: AI for Altium Designer", "brief": "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.",- "version": "0.2.89",+ "version": "0.2.90", "hero": { "type": "image", "path": "screenshots/hero.png"
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-0.2.89+0.2.90
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "altium", "displayName": "Altium Designer",- "version": "0.2.89",+ "version": "0.2.90", "description": "Drive Altium Designer from Adom: a resident DelphiScript agent (eval + the 1,100-command process launcher), the X2 -R command line, UIA over the VCL shell, dialogs by PID, screenshots of every Altium window, and Altium 365.", "homepage": "https://wiki.adom.inc/adom/altium-bridge", "docs": "https://wiki.adom.inc/adom/altium-bridge",