← Commit history

update_footprints_from_library (KiCad's verb, plan then apply); one Altium document per file whatever the path spelling

Colby Knox ·04d4256418 · ·parent 91470e9
10 files changed +471−28
CHANGELOG.md+20
@@ -1,5 +1,25 @@ # Changelog +## 0.2.84 (unreleased)++- **`altium_update_footprints_from_library`: bring placed parts up to the library's footprint.** KiCad's verb, same name+  and argument shape (`filePath`, `refs?`, `libraryPath?` or `libraries?`, `apply?`, `expectedRevision?`). It plans by+  default: each part's pads are compared with its library footprint in the part's own frame (a bottom part through its+  mirror, any rotation), and every row says `up_to_date`, `differs` (pads added, removed, or changed in position, size,+  drill, type or shape, and the 3D body count) or `library_not_found`. With no library named it searches the PcbLibs the+  board's project lists, the part's own source library first. `apply:true` replaces the differing parts in place:+  position, rotation, side, lock, designator and comment with their text positions, and every pad's net are kept, and+  a read-back re-diffs each replaced part and reports any that still differ under `problems`. Measured live in Altium+  Develop with pad 1 of TST_SOIC8 widened to 2 x 0.9 mm: the plan found U1 (top, 0 degrees) and U2 (bottom, 90 degrees)+  differing on pad 1 only; apply replaced both with their nets kept, both still at their places, and a second plan+  found them up to date while U3, not named, still differs.+- **One Altium document per file, whatever the spelling of its path.** Altium opens `C:/x/a.PcbLib` as a second+  document beside `C:\x\a.PcbLib`, so an edit on one copy was never seen by a read of the other (Battery.PcbLib was+  open three times). Every drive-letter path now reaches the agent with backslashes, and opening, closing and the+  library lookup match a document already open under any spelling.+- `routing_state` components carry `library`, the footprint library a part was placed from; a pad of shape 9 (the rounded rectangle of newer libraries) reads as+  `roundrect`.+ ## 0.2.83  - **Large boards read about 20 times faster.** The agent joined each list of the board model by appending to one growing
README.md+5−4
@@ -15,7 +15,7 @@ normal session. Ask in plain words and it: - makes the outputs: Gerbers, NC drill, pick and place, BOMs grouped by MPN (JLCPCB, Mouser, DigiKey files),   schematic PDF and STEP, checking that the outline and every copper layer reached the Gerbers -257 commands, tested on Altium Designer 26.11 and Altium Designer Develop. It runs in **Hydrogen**, Adom's free+258 commands, tested on Altium Designer 26.11 and Altium Designer Develop. It runs in **Hydrogen**, Adom's free desktop app, through Adom Bridge. You bring your own AI subscription and your own Altium licence.  ::youtube{id="dFecpcIzdSE" title="An AI designs a 12 V to 5 V buck converter in Altium Designer"}@@ -29,7 +29,7 @@ and the verb prefix `altium_`.  ## What it can do -Tested on Altium Designer 26.11.1 and Altium Designer Develop. 257 verbs; each row names the ones+Tested on Altium Designer 26.11.1 and Altium Designer Develop. 258 verbs; each row names the ones behind it (prefix `altium_`).  | Area | What the AI can do | Verbs |@@ -70,7 +70,7 @@ This bridge is the reference for the [EDA Bridge Standard](https://wiki.adom.inc  Altium Designer is the user's own **host app**. The bridge finds an installed Altium (`%ProgramFiles%\Altium\AD*\X2.EXE`, Designer or Develop), starts it in the background, runs a small-**DelphiScript agent** inside it, and gives the AI 257 `altium_*` verbs.+**DelphiScript agent** inside it, and gives the AI 258 `altium_*` verbs.  - **Page and docs:** https://wiki.adom.inc/adom/altium-bridge - **Bridge SDK:** https://wiki.adom.inc/adom/adom-bridge-sdk@@ -170,7 +170,7 @@ way to read it). A stopped engine is restarted with `altium_agent_recover`.  <!-- verbs:start (tools/readme_verbs.py writes this list) --> -All 257 verbs, by area (prefix `altium_`). `altium_describe` returns the live catalog with every input, output, hint and example.+All 258 verbs, by area (prefix `altium_`). `altium_describe` returns the live catalog with every input, output, hint and example.  ### Running Altium: launch, close, health, dialogs @@ -251,6 +251,7 @@ All 257 verbs, by area (prefix `altium_`). `altium_describe` returns the live ca - `altium_estimate_cost`: The numbers a fab quote needs (size, copper layers, thickness, smallest track, gap and drill, holes, parts and joints) from the board, and a rough price table at the quantities asked when you pass a price record read from the fab's own page (the standard's shared estimator; it has no rates of its own). - `altium_simulate`: Run a circuit simulation of a schematic sheet in Altium's mixed-signal simulator (Advanced Sim) and return the signals as data: an operating point, a DC sweep, an AC sweep or a transient, as the standard's simulate gives them. - `altium_export_spice`: The schematic's SPICE netlist from Altium's mixed-signal simulator (the .nsx its Mixed Sim output writes): elements, analyses, models.+- `altium_update_footprints_from_library`: Compare each placed footprint with its library's current one and, with apply:true, replace the ones that differ, keeping where the part sits (position, rotation, side), its designator and comment, its pad nets by pad number and its schematic link. - `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/agent.rs+17−1
@@ -163,6 +163,14 @@ pub fn call(command: &str, params: &[(&str, String)], payload: Option<&str>, tim /// The agent command currently posted (the agent serves one at a time): named in agent_busy. static IN_FLIGHT: std::sync::Mutex<Option<(String, Instant)>> = std::sync::Mutex::new(None); +/// A Windows path in one spelling: Altium opens a SECOND document for the same file under another spelling+/// (C:/x/a.PcbLib beside C:\x\a.PcbLib), and an edit made on one was never seen by a read of the other (three+/// copies of Battery.PcbLib, 2026-10-30). Every drive-letter path goes to the agent with backslashes.+pub fn win_path(v: &str) -> String {+    let b = v.as_bytes();+    if b.len() >= 3 && b[0].is_ascii_alphabetic() && b[1] == b':' && (b[2] == b'/' || b[2] == b'\\') { v.replace('/', "\\") } else { v.to_string() }+}+ pub fn call_in(ws: &std::path::Path, command: &str, params: &[(&str, String)], payload: Option<&str>, timeout: Duration) -> Value {     let ws = ws.to_path_buf();     let id = rid();@@ -171,7 +179,7 @@ pub fn call_in(ws: &std::path::Path, command: &str, params: &[(&str, String)], p         if v.contains('\n') || v.contains('\r') {             return json!({"success": false, "error": format!("param {k} must be single-line; use payload")});         }-        lines.push(format!("{k}={v}"));+        lines.push(format!("{k}={}", win_path(v)));     }     let inbox = ws.join("request.txt");     let t0 = Instant::now();@@ -301,6 +309,14 @@ pub fn is_agent_script_title(title: &str) -> bool { mod halt_tests {     use super::*; +    #[test]+    fn one_spelling_per_windows_path() {+        assert_eq!(win_path("C:/x/y\\a.PcbLib"), "C:\\x\\y\\a.PcbLib");+        assert_eq!(win_path("C:\\x\\a.PcbLib"), "C:\\x\\a.PcbLib");+        assert_eq!(win_path("TST_SOIC8"), "TST_SOIC8");+        assert_eq!(win_path("1/2"), "1/2", "not a path");+    }+     #[test]     fn agent_script_title_is_recognised() {         assert!(is_agent_script_title("AdomAgent_00fc18631e.PrjScr - Altium Designer Develop"));
bridge-rs/src/fpupdate.rsadded+238
@@ -0,0 +1,238 @@+//! update_footprints_from_library: compare each placed footprint with its library's current one (pads by number:+//! added, removed, moved, resized, reshaped, redrilled, relayered; 3D bodies) and, with apply:true, put the library's+//! footprint in place of each one that differs, keeping where the part sits, its designator and comment, its pad nets+//! and its schematic link. KiCad's verb of the same name, the same arguments and the same answer.+use serde_json::{json, Value};+use std::path::{Path, PathBuf};++fn f(v: &Value) -> f64 { v.as_f64().unwrap_or(0.0) }+fn r3(v: f64) -> f64 { (v * 1000.0).round() / 1000.0 }++/// The PcbLibs a project lists, as full paths. Pure apart from reading the project file.+fn project_libraries(board: &Path) -> Vec<PathBuf> {+    let dir = board.parent().unwrap_or(Path::new("."));+    let mut out = Vec::new();+    for e in std::fs::read_dir(dir).into_iter().flatten().flatten() {+        let p = e.path();+        if !p.extension().map(|x| x.eq_ignore_ascii_case("PrjPcb")).unwrap_or(false) { continue; }+        let text = std::fs::read_to_string(&p).unwrap_or_default();+        let name = board.file_name().map(|n| n.to_string_lossy().to_lowercase()).unwrap_or_default();+        if !text.to_lowercase().contains(&name) { continue; }+        for l in text.lines() {+            if let Some(d) = l.trim().strip_prefix("DocumentPath=") {+                if d.to_lowercase().ends_with(".pcblib") { out.push(dir.join(d.replace('\\', "/"))); }+            }+        }+    }+    out+}++/// One pad as the comparison sees it: number, position in the footprint's frame, size, rotation, drill, shape, side.+#[derive(Debug, Clone)]+pub struct P { pub num: String, pub x: f64, pub y: f64, pub w: f64, pub h: f64, pub rot: f64, pub drill: f64, pub shape: String, pub smd: bool }++/// A placed part's pads in its footprint's own frame, for each way the part might be turned and mirrored: rotation+/// undone, and for a bottom part the mirror undone in x or in y (the comparison keeps whichever fits). Pure.+pub fn placed_frames(comp: &Value, pads: &[&Value]) -> Vec<Vec<P>> {+    let (cx, cy, rot) = (f(&comp["x"]), f(&comp["y"]), f(&comp["rotation"]));+    let bottom = comp["side"] == "bottom";+    let mirrors: &[(f64, f64, f64)] = if bottom { &[(-1.0, 1.0, 1.0), (1.0, -1.0, 1.0), (-1.0, 1.0, -1.0), (1.0, -1.0, -1.0)] } else { &[(1.0, 1.0, 1.0)] };+    mirrors.iter().map(|(mx, my, sense)| {+        let a = (-rot * sense).to_radians();+        let (c, s) = (a.cos(), a.sin());+        pads.iter().map(|p| {+            let (dx, dy) = (f(&p["x"]) - cx, f(&p["y"]) - cy);+            let (lx, ly) = (dx * c - dy * s, dx * s + dy * c);+            P { num: p["name"].as_str().unwrap_or("").to_string(), x: lx * mx, y: ly * my, w: f(&p["sizeX"]), h: f(&p["sizeY"]),+                rot: (f(&p["rotation"]) - rot * sense).rem_euclid(180.0), drill: f(&p["drill"]), shape: p["shape"].as_str().unwrap_or("").to_string(),+                smd: f(&p["drill"]) == 0.0 }+        }).collect()+    }).collect()+}++/// The library footprint's pads (read_footprint's pads). Pure.+pub fn library_pads(fp: &Value) -> Vec<P> {+    fp["pads"].as_array().cloned().unwrap_or_default().iter().map(|p| P {+        num: p["number"].as_str().map(String::from).unwrap_or_else(|| p["number"].to_string()), x: f(&p["at"][0]), y: f(&p["at"][1]),+        w: f(&p["sizeMm"][0]), h: f(&p["sizeMm"][1]), rot: f(&p["rotation"]).rem_euclid(180.0), drill: f(&p["drillMm"]),+        shape: p["shape"].as_str().unwrap_or("").to_string(), smd: p["type"] == "smd",+    }).collect()+}++/// What differs between a placed footprint (in one of its frames) and the library's: pads added and removed by number,+/// and per pad what changed. Tolerance 0.002 mm and 0.1 degree. Pure.+pub fn diff(placed: &[P], lib: &[P]) -> (Vec<String>, Vec<String>, Vec<Value>) {+    let near = |a: f64, b: f64, t: f64| (a - b).abs() <= t;+    let mut added: Vec<String> = lib.iter().filter(|l| !placed.iter().any(|p| p.num == l.num)).map(|l| l.num.clone()).collect();+    let mut removed: Vec<String> = placed.iter().filter(|p| !lib.iter().any(|l| l.num == p.num)).map(|p| p.num.clone()).collect();+    added.sort(); added.dedup(); removed.sort(); removed.dedup();+    let mut changed = Vec::new();+    let mut used = vec![false; lib.len()];+    for p in placed {+        // a number can be on several pads (a thermal pad's vias): match each placed pad to the nearest unused one+        let Some(i) = (0..lib.len()).filter(|i| !used[*i] && lib[*i].num == p.num)+            .min_by(|a, b| ((lib[*a].x - p.x).hypot(lib[*a].y - p.y)).partial_cmp(&(lib[*b].x - p.x).hypot(lib[*b].y - p.y)).unwrap()) else { continue };+        used[i] = true;+        let l = &lib[i];+        let mut what = Vec::new();+        if !near(p.x, l.x, 0.002) || !near(p.y, l.y, 0.002) { what.push(format!("moved from ({}, {}) to ({}, {})", r3(p.x), r3(p.y), r3(l.x), r3(l.y))); }+        // a pad turned a quarter is the same copper with its sizes swapped+        let quarter = (((p.rot - l.rot).rem_euclid(180.0)) - 90.0).abs() < 0.1;+        let (lw, lh) = if quarter { (l.h, l.w) } else { (l.w, l.h) };+        if !near(p.w, lw, 0.002) || !near(p.h, lh, 0.002) { what.push(format!("size {} x {} to {} x {}", r3(p.w), r3(p.h), r3(l.w), r3(l.h))); }+        if !near(p.drill, l.drill, 0.002) { what.push(format!("drill {} to {}", r3(p.drill), r3(l.drill))); }+        if p.smd != l.smd { what.push(if l.smd { "through-hole to surface".into() } else { "surface to through-hole".into() }); }+        if !p.shape.is_empty() && !l.shape.is_empty() && p.shape != l.shape && !(p.shape.contains("rect") && l.shape.contains("rect") && p.shape != "roundrect" && l.shape != "roundrect") {+            what.push(format!("shape {} to {}", p.shape, l.shape));+        }+        if !what.is_empty() { changed.push(json!({"pad": p.num, "changes": what})); }+    }+    (added, removed, changed)+}++/// The best fit over a part's frames: the one with the fewest differences.+pub fn best_diff(frames: &[Vec<P>], lib: &[P]) -> (Vec<String>, Vec<String>, Vec<Value>) {+    frames.iter().map(|fr| diff(fr, lib)).min_by_key(|(a, r, c)| a.len() + r.len() + c.len()).unwrap_or_default()+}++/// altium_update_footprints_from_library {filePath, refs?, apply?, libraryPath? | libraries?}+pub fn update_footprints_from_library(args: &Value) -> Value {+    if let Some(g) = crate::support::need_licensed() { return g; }+    let Some(board) = crate::support::s(args, "filePath").filter(|p| p.to_lowercase().ends_with(".pcbdoc")) else {+        return json!({"success": false, "errorCode": "bad_args", "error": "filePath (the .PcbDoc) is required"});+    };+    if let Some(e) = crate::support::must_open(&board, 60) { return e; }+    let st = crate::routing::routing_state(&json!({}));+    if st.get("success").and_then(|v| v.as_bool()) != Some(true) { return st; }+    let revision = st["revision"].clone();+    // the libraries: those named, else the project's+    let mut libs: Vec<PathBuf> = args.get("libraries").and_then(|v| v.as_array()).map(|a| a.iter().filter_map(|x| x.as_str()).map(PathBuf::from).collect()).unwrap_or_default();+    if let Some(l) = crate::support::s(args, "libraryPath") { libs.push(PathBuf::from(l)); }+    if libs.is_empty() { libs = project_libraries(Path::new(&board.replace('\\', "/"))); }+    let refs: Vec<String> = args.get("refs").and_then(|v| v.as_array()).map(|a| a.iter().filter_map(|x| x.as_str().map(|s| s.to_ascii_uppercase())).collect()).unwrap_or_default();+    let comps: Vec<Value> = st["components"].as_array().cloned().unwrap_or_default().into_iter()+        .filter(|c| refs.is_empty() || refs.contains(&c["ref"].as_str().unwrap_or("").to_ascii_uppercase())).collect();+    if comps.is_empty() { return json!({"success": false, "errorCode": "no_such_part", "error": format!("none of {refs:?} is on the board")}); }+    let all_pads: Vec<Value> = st["pads"].as_array().cloned().unwrap_or_default();+    // each footprint read once from the library it is in (its source library first, by file name)+    let mut cache: std::collections::HashMap<(String, String), Option<(PathBuf, Value)>> = std::collections::HashMap::new();+    let mut misses: std::collections::HashMap<(String, String), String> = std::collections::HashMap::new();+    let mut rows = Vec::new();+    for c in &comps {+        let r = c["ref"].as_str().unwrap_or("").to_string();+        let pattern = c["pattern"].as_str().unwrap_or("").to_string();+        let src = c["library"].as_str().unwrap_or("").to_lowercase();+        let key = (pattern.to_lowercase(), src.clone());+        if !cache.contains_key(&key) {+            let mut order: Vec<&PathBuf> = libs.iter().filter(|l| l.file_name().map(|n| n.to_string_lossy().to_lowercase() == src).unwrap_or(false)).collect();+            order.extend(libs.iter().filter(|l| l.file_name().map(|n| n.to_string_lossy().to_lowercase() != src).unwrap_or(true)));+            let mut hit = None;+            for l in order {+                let fp = crate::project::read_footprint(&json!({"libraryPath": l.to_string_lossy().replace('\\', "/"), "name": pattern}));+                if fp.get("success").and_then(|v| v.as_bool()) == Some(true) { hit = Some((l.clone(), fp)); break; }+                misses.insert(key.clone(), format!("{}: {}", l.display(), fp.get("error").and_then(|e| e.as_str()).unwrap_or("not read")));+            }+            cache.insert(key.clone(), hit);+        }+        let Some((lib, fp)) = cache.get(&key).cloned().flatten() else {+            rows.push(json!({"ref": r, "footprint": pattern, "status": "library_not_found",+                "why": if libs.is_empty() { "no library given, and the board's project lists no .PcbLib".to_string() } else { format!("{pattern} is in none of {} libraries", libs.len()) },+                "lastError": misses.get(&key)}));+            continue;+        };+        let pads: Vec<&Value> = all_pads.iter().filter(|p| p["ref"].as_str() == Some(r.as_str())).collect();+        let (added, removed, changed) = best_diff(&placed_frames(c, &pads), &library_pads(&fp));+        let lib_bodies = fp["models"].as_array().map(|a| a.len()).unwrap_or(0) as i64;+        let board_bodies = c["bodies"].as_i64().unwrap_or(0);+        let bodies_differ = lib_bodies != board_bodies;+        let differs = !added.is_empty() || !removed.is_empty() || !changed.is_empty() || bodies_differ;+        let mut row = json!({"ref": r, "footprint": pattern, "library": lib.to_string_lossy(), "status": if differs { "differs" } else { "up_to_date" },+            "padsCompared": {"board": pads.len(), "library": library_pads(&fp).len()}});+        if differs {+            row["diff"] = json!({"padsAdded": added, "padsRemoved": removed, "padsChanged": changed});+            if bodies_differ { row["diff"]["bodies3d"] = json!({"board": board_bodies, "library": lib_bodies}); }+        }+        rows.push(row);+    }+    let differing: Vec<Value> = rows.iter().filter(|r| r["status"] == "differs").cloned().collect();+    if args.get("apply").and_then(|v| v.as_bool()) != Some(true) || differing.is_empty() {+        return json!({"success": true, "plan": true, "mutated": false, "footprints": rows, "differs": differing.len(), "revision": revision,+            "_hint": if differing.is_empty() { "Every footprint matches its library." } else { "A plan: nothing changed. Read each diff (a pad new in the library gets no net; a removed pad's net goes with it), then call again with apply:true to replace the differing ones." }});+    }+    if let Some(rev) = args.get("expectedRevision").and_then(|v| v.as_str()) {+        if revision.as_str() != Some(rev) { return json!({"success": false, "errorCode": "stale_board", "error": format!("the board changed since revision {rev}")}); }+    }+    // reading the libraries made them the current documents: the board comes back to the front first+    if let Some(e) = crate::support::must_open(&board, 60) { return e; }+    let mut done = Vec::new();+    for row in &differing {+        let a = crate::agent::call("replace_fp", &[("ref", row["ref"].as_str().unwrap_or("").to_string()), ("libraryPath", row["library"].as_str().unwrap_or("").replace('/', "\\")),+            ("footprint", row["footprint"].as_str().unwrap_or("").to_string())], None, std::time::Duration::from_secs(120));+        let d = a.get("data").cloned().unwrap_or(Value::Null);+        done.push(json!({"ref": row["ref"], "replaced": d["ok"] == json!(true), "netsKept": d["netsKept"], "netsBefore": d["netsBefore"], "error": d["error"]}));+    }+    // read back: every replaced part where it was, and now matching its library+    let after = crate::routing::routing_state(&json!({}));+    let mut problems = Vec::new();+    for row in &differing {+        let r = row["ref"].as_str().unwrap_or("");+        let before = comps.iter().find(|c| c["ref"].as_str() == Some(r));+        let now = after["components"].as_array().and_then(|a| a.iter().find(|c| c["ref"].as_str() == Some(r)).cloned());+        match (before, now) {+            (Some(b), Some(n)) => {+                if (f(&b["x"]) - f(&n["x"])).abs() > 0.001 || (f(&b["y"]) - f(&n["y"])).abs() > 0.001 || b["side"] != n["side"]+                    || ((f(&b["rotation"]) - f(&n["rotation"])).rem_euclid(360.0)).min((f(&n["rotation"]) - f(&b["rotation"])).rem_euclid(360.0)) > 0.01 {+                    problems.push(json!({"ref": r, "problem": "moved", "before": [b["x"], b["y"], b["rotation"], b["side"]], "after": [n["x"], n["y"], n["rotation"], n["side"]]}));+                }+                let pads: Vec<&Value> = after["pads"].as_array().map(|a| a.iter().filter(|p| p["ref"].as_str() == Some(r)).collect()).unwrap_or_default();+                let key = (row["footprint"].as_str().unwrap_or("").to_lowercase(), b["library"].as_str().unwrap_or("").to_lowercase());+                if let Some(Some((_, fp))) = cache.get(&key) {+                    let (ad, rm, ch) = best_diff(&placed_frames(&n, &pads), &library_pads(fp));+                    if !ad.is_empty() || !rm.is_empty() || !ch.is_empty() { problems.push(json!({"ref": r, "problem": "still differs", "padsAdded": ad, "padsRemoved": rm, "padsChanged": ch})); }+                }+            }+            _ => problems.push(json!({"ref": r, "problem": "not on the board after the replace"})),+        }+    }+    json!({"success": problems.is_empty() && done.iter().all(|d| d["replaced"] == json!(true)), "plan": false, "mutated": true, "footprints": rows, "replaced": done,+        "problems": problems, "revision": after["revision"], "unconnected": after["unconnected"],+        "_hint": "Each part was replaced by its library's footprint where it sat, with its designator, comment, nets (by pad number) and schematic link. Tracks were not moved to follow pads that moved: run altium_routing_drc. Save with altium_save."})+}++#[cfg(test)]+mod tests {+    use super::*;++    fn pad(r: &str, n: &str, x: f64, y: f64, w: f64, h: f64, rot: f64) -> Value {+        json!({"ref": r, "name": n, "x": x, "y": y, "sizeX": w, "sizeY": h, "rotation": rot, "drill": 0.0, "shape": "rect"})+    }++    #[test]+    fn a_turned_part_matches_its_library_and_a_changed_pad_is_named() {+        // a two-pad part at (10, 20) turned 90: library pads at (-1, 0) and (1, 0), 0.6 x 0.5+        let comp = json!({"ref": "R1", "x": 10.0, "y": 20.0, "rotation": 90.0, "side": "top"});+        let p1 = pad("R1", "1", 10.0, 19.0, 0.6, 0.5, 90.0);+        let p2 = pad("R1", "2", 10.0, 21.0, 0.6, 0.5, 90.0);+        let lib = vec![P { num: "1".into(), x: -1.0, y: 0.0, w: 0.6, h: 0.5, rot: 0.0, drill: 0.0, shape: "rect".into(), smd: true },+                       P { num: "2".into(), x: 1.0, y: 0.0, w: 0.6, h: 0.5, rot: 0.0, drill: 0.0, shape: "rect".into(), smd: true }];+        let (a, r, c) = best_diff(&placed_frames(&comp, &[&p1, &p2]), &lib);+        assert!(a.is_empty() && r.is_empty() && c.is_empty(), "{a:?} {r:?} {c:?}");+        let mut lib2 = lib.clone();+        lib2[1].w = 0.8;+        lib2.push(P { num: "3".into(), x: 0.0, y: 1.0, w: 0.3, h: 0.3, rot: 0.0, drill: 0.0, shape: "rect".into(), smd: true });+        let (a, _, c) = best_diff(&placed_frames(&comp, &[&p1, &p2]), &lib2);+        assert_eq!(a, vec!["3".to_string()]);+        assert_eq!(c.len(), 1);+        assert_eq!(c[0]["pad"], "2");+    }++    #[test]+    fn a_bottom_part_is_seen_through_its_mirror() {+        let comp = json!({"ref": "U1", "x": 0.0, "y": 0.0, "rotation": 0.0, "side": "bottom"});+        // library pad 1 at (-1, 0.5); on the bottom it shows at (1, 0.5)+        let p1 = pad("U1", "1", 1.0, 0.5, 0.4, 0.4, 0.0);+        let lib = vec![P { num: "1".into(), x: -1.0, y: 0.5, w: 0.4, h: 0.4, rot: 0.0, drill: 0.0, shape: "rect".into(), smd: true }];+        let (a, r, c) = best_diff(&placed_frames(&comp, &[&p1]), &lib);+        assert!(a.is_empty() && r.is_empty() && c.is_empty(), "{c:?}");+    }+}
bridge-rs/src/main.rs+1
@@ -31,6 +31,7 @@ mod footprint; mod hier; mod coppermap; mod current;+mod fpupdate; mod impedance; mod inspect; mod lengths;
bridge-rs/src/routing.rs+2−2
@@ -107,7 +107,7 @@ fn i(v: &Value) -> i64 {  /// Altium's pad shape id (TShape) as a name. fn pad_shape(id: i64) -> &'static str {-    match id { 1 => "round", 2 => "rect", 3 => "octagonal", 4 => "circle", 7 => "roundrect", 8 => "rotated-rect", _ => "other" }+    match id { 1 => "round", 2 => "rect", 3 => "octagonal", 4 => "circle", 7 | 9 => "roundrect", 8 => "rotated-rect", _ => "other" } }  // -- connectivity from the copper itself -------------------------------------------------------@@ -247,7 +247,7 @@ pub fn shape(d: &Value) -> Value {     let comps: Vec<Value> = arr(d, "comps").iter().map(|c| json!({         "ref": c[0], "x": mm(&c[1]), "y": mm(&c[2]), "rotation": deg(&c[3]),         "side": if i(&c[4]) == BOTTOM { "bottom" } else { "top" }, "pattern": c[5], "bodies": c.get(6).cloned().unwrap_or(json!(null)),-        "has3d": c.get(6).and_then(|b| b.as_i64()).map(|b| b > 0)})).collect();+        "has3d": c.get(6).and_then(|b| b.as_i64()).map(|b| b > 0), "library": c.get(7).cloned().unwrap_or(Value::Null)})).collect();     let polys: Vec<Value> = arr(d, "polys").iter().map(|g| json!({         "net": g[0], "layer": layer_name(i(&g[1])), "layerId": g[1],         "points": poly_ring(g[2].as_array().map(|v| v.as_slice()).unwrap_or(&[]))})).collect();
bridge-rs/src/verbs.rs+7−1
@@ -22,7 +22,7 @@ pub const KNOWN: &[&str] = &[     "list_nets", "net_connections", "layers", "copper_layers", "read_rules",     "set_layer_visibility", "footprint_primitives", "schematic_data", "layer_stack", "net_classes", "diff_pairs", "board_outline", "set_track_width", "find_space", "selection", "check_orientation", "replicate_layout", "outjob_info", "find_symbol", "part_parameters",     // the live-board lane AI Flow drives-    "routing_state", "route_net", "plan_route", "move_parts", "place_decoupling", "plan_fanout", "estimate_cost", "simulate", "export_spice", "export_library_part", "create_part_project", "library_views", "render_board_3d", "render_board_layers", "document_info", "close_all_documents", "project_info", "project_create", "project_rename", "project_snapshot", "cross_probe", "read_footprint", "export_odb", "export_ipc2581", "export_ipc356", "export_dxf", "export_gencad", "import_svg", "edit_footprint", "generate_body", "remove_parts", "edit_parts", "align_parts", "set_layer_count", "copy_routing", "check_clearance", "remove_graphics", "place_vias", "board_features", "sch_sheet_symbol", "netlist", "silkscreen_prep", "net_lengths", "teardrops", "component_classes", "read_sheet_file", "fab_check", "panelize", "impedance", "current_capacity", "height_check", "bodies", "copper_balance", "return_path", "silk_designators", "via_fence", "assembly_check", "jlcpcb_order", "schematic_review", "pin_pad_check", "route_pair", "thermal_vias", "board_report", "placement_check", "auto_classes", "length_tune", "remove_items", "ripup_nets", "apply_pours", "pour_state", "remove_pours", "repour", "routing_drc", "build_board", "set_outline", "set_design_rules", "zoom_to", "add_rule", "build_schematic", "export_manufacturing", "select_net", "silk_state", "apply_silkscreen",+    "routing_state", "route_net", "plan_route", "move_parts", "place_decoupling", "plan_fanout", "estimate_cost", "simulate", "export_spice", "update_footprints_from_library", "export_library_part", "create_part_project", "library_views", "render_board_3d", "render_board_layers", "document_info", "close_all_documents", "project_info", "project_create", "project_rename", "project_snapshot", "cross_probe", "read_footprint", "export_odb", "export_ipc2581", "export_ipc356", "export_dxf", "export_gencad", "import_svg", "edit_footprint", "generate_body", "remove_parts", "edit_parts", "align_parts", "set_layer_count", "copy_routing", "check_clearance", "remove_graphics", "place_vias", "board_features", "sch_sheet_symbol", "netlist", "silkscreen_prep", "net_lengths", "teardrops", "component_classes", "read_sheet_file", "fab_check", "panelize", "impedance", "current_capacity", "height_check", "bodies", "copper_balance", "return_path", "silk_designators", "via_fence", "assembly_check", "jlcpcb_order", "schematic_review", "pin_pad_check", "route_pair", "thermal_vias", "board_report", "placement_check", "auto_classes", "length_tune", "remove_items", "ripup_nets", "apply_pours", "pour_state", "remove_pours", "repour", "routing_drc", "build_board", "set_outline", "set_design_rules", "zoom_to", "add_rule", "build_schematic", "export_manufacturing", "select_net", "silk_state", "apply_silkscreen",     // surfaces     "show_project", "show_schematic", "show_2d_board", "show_3d_board", "show_library",     "show_symbol", "show_footprint", "show_3d_chip", "list_library", "demo",@@ -442,6 +442,11 @@ fn describe() -> Value {             json!({"path": "the netlist", "elements": "[element lines]", "analyses": "[.AC / .TRAN / .DC / .OP lines]", "includes": "[.INCLUDE / .LIB lines]", "format": "string"}), 900,             "Altium writes this netlist only as part of a run, so the sheet is simulated too (its results land in the project's Simulation folder). Models come inline (.model, .subckt) or as includes. elements are exact; analyses are the lines Altium wrote, which can lag a sheet's newest settings by a run (measured: a transient ran while the file still read its earlier .AC): altium_simulate reports the analysis that ran.",             &["simulate"], &["A part with no simulation model stops the netlister: export_failed."], json!({"schematic": "C:/proj/Filter.SchDoc", "outputPath": "C:/proj/Filter.cir"})),+        verb_doc("update_footprints_from_library", "Compare each placed footprint with its library's current one and, with apply:true, replace the ones that differ, keeping where the part sits (position, rotation, side), its designator and comment, its pad nets by pad number and its schematic link. KiCad's verb of the same name.",+            json!({"filePath": "the .PcbDoc (required)", "refs": "[\"U1\"] (default every footprint)", "apply": "bool, default false: a plan; true replaces every differing footprint", "libraryPath": "a .PcbLib to take footprints from (default: the .PcbLibs the board's project lists; a part's own source library first)", "libraries": "[.PcbLib]: several", "expectedRevision": "string: refuse with stale_board if the board changed since the plan"}),+            json!({"footprints": "[{ref, footprint, library, status: up_to_date | differs | library_not_found, diff?: {padsAdded, padsRemoved, padsChanged: [{pad, changes}], bodies3d?}, why?}]", "differs": "int", "plan": "bool", "mutated": "bool", "replaced": "[{ref, replaced, netsKept, netsBefore}] (apply)", "problems": "[read-back problems] (apply)", "revision": "string"}), 600,+            "Plan first: each differing part's diff names the pads added, removed or changed (moved, resized, reshaped, redrilled, surface or through-hole) and a 3D body count that differs. apply:true replaces every differing part and reads them back: each must sit where it did and match its library. Save with altium_save.",+            &["edit_footprint", "footprint_from_land_pattern", "swap_footprint", "routing_drc", "save"], &["A pad new in the library has no net, and a removed pad's net goes with it: read padsAdded and padsRemoved before apply.", "Tracks are not moved to follow pads that moved: run altium_routing_drc after."], json!({"filePath": "C:/proj/Board.PcbDoc", "refs": ["U1"]})),         verb_doc("move_parts", "Move, rotate and flip placed components (side top or bottom; flip:true turns a part over); each part is read back to 0.001 mm, the exact rotation and its side. One undo step.",             json!({"parts": "[{ref, x, y, rotation, side?: top|bottom, flip?: bool}] - mm and degrees, Altium's frame; or {ref, dx, dy} to move by an offset; rotation and side kept when left out", "expectedRevision": "string (optional) - the revision you last read; refused with stale_board if the board changed", "boardId": "string (optional) - refused with board_mismatch unless this is the current board", "expectPath": "string (optional)"}),             json!({"revision": "string", "results": "[ok|err:...]", "mismatches": "[{ref, asked, got}] when a part did not land where asked (errorCode readback_mismatch)"}), 300,@@ -2178,6 +2183,7 @@ pub fn dispatch(command: &str, args: &Value, _forwarded: &[(String, String)]) ->         "copy_footprint" => library::copy_footprint(args),         "xcopy_footprint" => library::xcopy_footprint(args),         "swap_footprint" => library::swap_footprint(args),+        "update_footprints_from_library" => crate::fpupdate::update_footprints_from_library(args),         "symbol_mode" => library::symbol_mode(args),         "cleanup_libs" => library::cleanup_libs(args),         "install_library" => library::install_library(args),
dev-skills/altium-bridge-test/run_verb_tests.py+4
@@ -223,6 +223,10 @@ def matrix(w):                                                              holeToHole=0.25, polygonConnect="relief"))     M["add_rule"] = dict(phase=3.5, **ok(kind="clearance", name="Battery", scope1="InNet('N1')", gap=0.3))     M["move_parts"] = dict(phase=3.5, **ok(parts=[{"ref": "U2", "x": 29, "y": 10, "rotation": 0}], expectPath=LB))+    # 0.2.84: both SOICs were just placed from PL, so a plan finds them up to date (U2 turned, then moved, still matches)+    M["update_footprints_from_library"] = dict(phase=3.5, timeout=300, **ok(filePath=LB, refs=["U1", "U2"], libraryPath=PL),+                                               check=lambda d: d.get("plan") is True and d.get("differs") == 0+                                               and [r.get("status") for r in d.get("footprints") or []] == ["up_to_date"] * 2)     # 0.2.80: the standard's planner (#21) finds N1 across the lane board; a plan changes nothing     # 0.2.80: the standard's decoupling planner (#22); the lane board's SOICs have no caps, so a named refusal or an empty plan     M["place_decoupling"] = dict(phase=3.5, timeout=300, **anyo("U1 on the lane board: no caps, an empty plan", ic="U1", filePath=LB))
src/agent/AdomAgent.pas.tmpl+175−19
@@ -420,6 +420,42 @@ Begin     Result := '{' + JRaw('ok', 'true') + ',' + JStr('process', Cmd) + ',' + JStr('params', P) + '}'; End; +{ a path in one spelling, to compare two: backslashes, upper case }+Function SamePathText(P : String) : String;+Var+    K : Integer;+Begin+    Result := '';+    For K := 1 To Length(P) Do+        If Copy(P, K, 1) = '/' Then Result := Result + '\' Else Result := Result + Copy(P, K, 1);+    Result := UpperCase(Result);+End;++{ The document open at Path under any spelling of it (C:/x/a.PcbLib is C:\x\a.PcbLib), Nil when none. GetDocumentByPath+  matches the spelling exactly, so a second open made Altium hold a second copy of the file, and an edit on one copy+  was never seen by a read of the other (three copies of Battery.PcbLib, 2026-10-30). }+Function DocAt(Path : String) : IServerDocument;+Var+    SM   : IServerModule;+    D    : IServerDocument;+    I, J : Integer;+Begin+    Result := Nil;+    Try Result := Client.GetDocumentByPath(Path); Except Result := Nil; End;+    If Result <> Nil Then Exit;+    For I := 0 To Client.Count - 1 Do+    Begin+        SM := Client.ServerModule[I];+        If SM = Nil Then Continue;+        For J := 0 To SM.DocumentCount - 1 Do+        Begin+            D := SM.Documents[J];+            If (D <> Nil) And (Result = Nil) Then+                If SamePathText(D.FileName) = SamePathText(Path) Then Result := D;+        End;+    End;+End;+ { Open a document or project by path. Client.OpenDocument('', path) returns Nil on   AD 26.9.1 (measured), so go through the WorkspaceManager process launcher, then   look the document up and show it. .PrjPcb/.PrjScr/.PrjMbd open as a Project. }@@ -462,11 +498,15 @@ Begin     End;     If Kind <> 'Project' Then     Begin-        Doc := Nil;-        Try-            Doc := Client.OpenDocument(Kind, Path);-        Except-            Doc := Nil;+        { open under another spelling of the path, it is this file: opening it again makes a second copy }+        Doc := DocAt(Path);+        If Doc = Nil Then+        Begin+            Try+                Doc := Client.OpenDocument(Kind, Path);+            Except+                Doc := Nil;+            End;         End;         If Doc <> Nil Then         Begin@@ -510,16 +550,6 @@ End; { Before a NEW document is named onto Path: close any document already open at that path, unless it has changes.   Altium holds a second document at the same path otherwise, and AD 26 (which reopens its last session) then crashed   in ADVPCB.DLL when DRC ran on the battery's board (measured 2026-10-27, twice). }-Function SamePathText(P : String) : String;-Var-    K : Integer;-Begin-    Result := '';-    For K := 1 To Length(P) Do-        If Copy(P, K, 1) = '/' Then Result := Result + '\' Else Result := Result + Copy(P, K, 1);-    Result := UpperCase(Result);-End;- Procedure FreePath(Path : String); Var     SM : IServerModule;@@ -567,7 +597,7 @@ Begin             For J := 0 To SM.DocumentCount - 1 Do             Begin                 D := SM.Documents[J];-                If (D <> Nil) And (UpperCase(D.FileName) = UpperCase(Path)) Then Doc := D;+                If (D <> Nil) And (SamePathText(D.FileName) = SamePathText(Path)) Then Doc := D;             End;         End;     End;@@ -6132,9 +6162,11 @@ Begin         Else If Prim.ObjectId = eComponentObject Then         Begin             Comp := Prim;+            Own := '';+            Try Own := Comp.SourceFootprintLibrary; Except Own := ''; End;             LC.Add('["' + JsonEsc(Comp.Name.Text) + '",' + IntToStr(Comp.x) + ',' + IntToStr(Comp.y) + ',' +                 IntToStr(Round(Comp.Rotation * 1000)) + ',' + IntToStr(Comp.Layer) + ',"' + JsonEsc(Comp.Pattern) + '",' +-                IntToStr(GroupCount(Comp, eComponentBodyObject)) + ']');+                IntToStr(GroupCount(Comp, eComponentBodyObject)) + ',"' + JsonEsc(Own) + '"]');         End         Else If Prim.ObjectId = ePolyObject Then         Begin@@ -7898,6 +7930,130 @@ Begin         JRaw('rows', IntToStr(E.RowCount)) + ',' + JRaw('cols', IntToStr(E.ColCount)) + '}'; End; +{ replace_fp: put a library's current footprint in place of a placed part's (update_footprints_from_library), keeping+  where it sits (position, rotation, side), its designator and comment and where they stand, its pad nets by pad name,+  its schematic link (Source* ids) and its lock. ref= libraryPath= footprint=. One undo step. The new copy is placed+  by its pads: the library pad matching a placed pad lands where that pad would (the library's origin moves with its+  current footprint, measured 2026-10-27), then the side and rotation are set as move_parts sets them. }+Function CmdReplaceFp(Lines : TStringList) : String;+Var+    Board : IPCB_Board;+    PLib  : IPCB_Library;+    LibFp : IPCB_LibComponent;+    Old, Inst : IPCB_Component;+    GIt   : IPCB_GroupIterator;+    Prim, Cpy : IPCB_Primitive;+    Pad, LP : IPCB_Pad;+    Net   : IPCB_Net;+    NetMap : TStringList;+    I, CX, CY, OX, OY, DX, DY, NX, NY, CmX, CmY, Nets : Integer;+    Rot : Double;+    Bottom, Locked, NOn, COn, Found : Boolean;+    Des, Cmt, SrcU, SrcD, SrcL, SrcC, SrcF, SrcH : String;+Begin+    Board := PCBServer.GetCurrentPCBBoard;+    If Board = Nil Then Begin Result := '{' + JRaw('ok','false') + ',' + JStr('errorCode','no_current_board') + ',' + JStr('error','no current PCB board') + '}'; Exit; End;+    Old := FindCompByDes(Board, Param(Lines, 'ref'));+    If Old = Nil Then Begin Result := '{' + JRaw('ok','false') + ',' + JStr('errorCode','no_such_part') + ',' + JStr('error','no part ' + Param(Lines, 'ref')) + '}'; Exit; End;+    PLib := PCBServer.LoadPCBLibraryByPath(Param(Lines, 'libraryPath'));+    If PLib = Nil Then Begin Result := '{' + JRaw('ok','false') + ',' + JStr('errorCode','library_not_found') + ',' + JStr('error','could not load ' + Param(Lines, 'libraryPath')) + '}'; Exit; End;+    LibFp := Nil;+    For I := 0 To PLib.ComponentCount - 1 Do+        If UpperCase(PLib.GetComponent(I).Name) = UpperCase(Param(Lines, 'footprint')) Then LibFp := PLib.GetComponent(I);+    If LibFp = Nil Then Begin Result := '{' + JRaw('ok','false') + ',' + JStr('errorCode','footprint_not_found') + ',' + JStr('error', Param(Lines, 'footprint') + ' is not in ' + Param(Lines, 'libraryPath')) + '}'; Exit; End;+    If PLib.CurrentComponent <> LibFp Then PLib.CurrentComponent := LibFp;+    OX := PLib.Board.XOrigin; OY := PLib.Board.YOrigin;+    { everything the part carries that the library does not }+    CX := Old.x; CY := Old.y; Rot := Old.Rotation; Bottom := Old.Layer = eBottomLayer; Locked := Not Old.Moveable;+    Des := Old.Name.Text; Cmt := Old.Comment.Text; NOn := Old.NameOn; COn := Old.CommentOn;+    NX := Old.Name.XLocation; NY := Old.Name.YLocation; CmX := Old.Comment.XLocation; CmY := Old.Comment.YLocation;+    SrcU := ''; SrcD := ''; SrcL := ''; SrcC := ''; SrcF := ''; SrcH := '';+    Try SrcU := Old.SourceUniqueId; SrcD := Old.SourceDesignator; SrcL := Old.SourceLibReference; SrcC := Old.SourceComponentLibrary; SrcF := Old.SourceFootprintLibrary; SrcH := Old.SourceHierarchicalPath; Except End;+    { the footprint now comes from this library: name it, as a part placed from it is named (the next plan tries it first) }+    SrcF := Param(Lines, 'libraryPath');+    I := Length(SrcF);+    While (I > 0) And (Copy(SrcF, I, 1) <> '\') Do I := I - 1;+    SrcF := Copy(SrcF, I + 1, Length(SrcF));+    NetMap := TStringList.Create;+    GIt := Old.GroupIterator_Create;+    GIt.AddFilter_ObjectSet(MkSet(ePadObject)); GIt.AddFilter_LayerSet(AllLayers);+    Pad := GIt.FirstPCBObject;+    While Pad <> Nil Do+    Begin+        If (Pad.Net <> Nil) And (NetMap.IndexOfName(Pad.Name) < 0) Then NetMap.Add(Pad.Name + '=' + Pad.Net.Name);+        Pad := GIt.NextPCBObject;+    End;+    Old.GroupIterator_Destroy(GIt);+    PCBServer.PreProcess;+    Inst := PCBServer.PCBObjectFactory(eComponentObject, eNoDimension, eCreate_Default);+    Inst.Layer := eTopLayer;+    GIt := LibFp.GroupIterator_Create;+    GIt.AddFilter_LayerSet(AllLayers);+    Prim := GIt.FirstPCBObject;+    While Prim <> Nil Do Begin Cpy := Prim.Replicate; Inst.AddPCBObject(Cpy); Prim := GIt.NextPCBObject; End;+    LibFp.GroupIterator_Destroy(GIt);+    Board.AddPCBObject(Inst);+    PCBServer.SendMessageToRobots(Board.I_ObjectAddress, c_Broadcast, PCBM_BoardRegisteration, Inst.I_ObjectAddress);+    Inst.x := CX; Inst.y := CY;+    { put the library's origin on the part's: a pad of the copy goes where its library pad sits from the origin }+    Found := False; DX := 0; DY := 0;+    GIt := LibFp.GroupIterator_Create;+    GIt.AddFilter_ObjectSet(MkSet(ePadObject)); GIt.AddFilter_LayerSet(AllLayers);+    LP := GIt.FirstPCBObject;+    LibFp.GroupIterator_Destroy(GIt);+    If LP <> Nil Then+    Begin+        GIt := Inst.GroupIterator_Create;+        GIt.AddFilter_ObjectSet(MkSet(ePadObject)); GIt.AddFilter_LayerSet(AllLayers);+        Pad := GIt.FirstPCBObject;+        While (Pad <> Nil) And (Not Found) Do+        Begin+            If (Pad.Name = LP.Name) And (Pad.TopXSize = LP.TopXSize) Then Begin DX := (LP.x - OX + CX) - Pad.x; DY := (LP.y - OY + CY) - Pad.y; Found := True; End;+            Pad := GIt.NextPCBObject;+        End;+        Inst.GroupIterator_Destroy(GIt);+    End;+    If (DX <> 0) Or (DY <> 0) Then+    Begin+        GIt := Inst.GroupIterator_Create;+        GIt.AddFilter_LayerSet(AllLayers);+        Prim := GIt.FirstPCBObject;+        While Prim <> Nil Do Begin If Prim.ObjectId <> eTextObject Then Prim.MoveByXY(DX, DY); Prim := GIt.NextPCBObject; End;+        Inst.GroupIterator_Destroy(GIt);+    End;+    Inst.BeginModify;+    If Bottom Then Inst.Layer := eBottomLayer;+    Inst.Rotation := Rot;+    Inst.MoveToXY(CX, CY);+    Inst.Pattern := LibFp.Name;+    Inst.Name.Text := Des; Inst.Comment.Text := Cmt; Inst.NameOn := NOn; Inst.CommentOn := COn;+    Try Inst.SourceUniqueId := SrcU; Inst.SourceDesignator := SrcD; Inst.SourceLibReference := SrcL; Inst.SourceComponentLibrary := SrcC; Inst.SourceFootprintLibrary := SrcF; Inst.SourceHierarchicalPath := SrcH; Except End;+    Inst.EndModify;+    Inst.Name.MoveToXY(NX, NY); Inst.Comment.MoveToXY(CmX, CmY);+    { the nets, pad by pad name }+    Nets := 0;+    GIt := Inst.GroupIterator_Create;+    GIt.AddFilter_ObjectSet(MkSet(ePadObject)); GIt.AddFilter_LayerSet(AllLayers);+    Pad := GIt.FirstPCBObject;+    While Pad <> Nil Do+    Begin+        If NetMap.IndexOfName(Pad.Name) >= 0 Then+        Begin+            Net := FindNet(Board, NetMap.Values[Pad.Name]);+            If Net <> Nil Then Begin Pad.BeginModify; Pad.Net := Net; Pad.EndModify; Net.AddPCBObject(Pad); Nets := Nets + 1; End;+        End;+        Pad := GIt.NextPCBObject;+    End;+    Inst.GroupIterator_Destroy(GIt);+    Board.RemovePCBObject(Old);+    If Locked Then Inst.Moveable := False;+    PCBServer.PostProcess;+    Board.ViewManager_FullUpdate;+    Result := '{' + JRaw('ok','true') + ',' + JStr('ref', Des) + ',' + JStr('footprint', LibFp.Name) + ',' + JRaw('placedByPad', JBool(Found)) + ',' ++        JRaw('padsOnPart', IntToStr(GroupCount(Inst, ePadObject))) + ',' + JRaw('netsKept', IntToStr(Nets)) + ',' + JRaw('netsBefore', IntToStr(NetMap.Count)) + '}';+    NetMap.Free;+End;+ { bodies: every 3D body on the board as [component, componentLayer, overallHeight, standoffHeight, left, bottom, right,   top, rotation*1000, outline] in internal units (the outline only for a part turned off the 90-degree grid). OverallHeight is the body's top above the board surface its part sits on and StandoffHeight   its bottom (measured on the Bluetooth Sentinel example, Develop 2026-10-23); a part with several bodies has several@@ -9555,8 +9711,7 @@ Var Begin     Result := '';     If Path = '' Then Exit;-    SD := Nil;-    Try SD := Client.GetDocumentByPath(Path); Except SD := Nil; End;+    SD := DocAt(Path);     If SD = Nil Then Begin Result := Path + ' is not open in Altium'; Exit; End;     PL := PCBServer.GetCurrentPCBLibrary;     If (PL <> Nil) And (SamePathText(PL.Board.FileName) = SamePathText(Path)) Then Exit;@@ -10152,6 +10307,7 @@ Begin     Else If Cmd = 'test_board' Then Result := CmdTestBoard(Lines)     Else If Cmd = 'board_shape' Then Result := CmdBoardShape(Lines)     Else If Cmd = 'swap_footprint' Then Result := CmdSwapFootprint(Lines)+    Else If Cmd = 'replace_fp' Then Result := CmdReplaceFp(Lines)     Else If Cmd = 'tx_clear' Then Begin TxClear; Result := '{' + JRaw('ok','true') + ',' + JStr('note','PCBServer transaction cleared') + '}'; End     Else If Cmd = 'stop' Then     Begin
src/bridge.json+2−1
@@ -196,6 +196,7 @@     "altium_estimate_cost",     "altium_simulate",     "altium_export_spice",+    "altium_update_footprints_from_library",     "altium_route_pair",     "altium_routing_drc",     "altium_routing_state",@@ -289,7 +290,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,+      "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,       "height_check": 150,       "copper_balance": 240,       "return_path": 240,