← Commit history
CHANGELOG.md+22
@@ -1,5 +1,27 @@ # Changelog +## 0.2.85++- **Four verbs new in the standard** (EDA Bridge Standard #29, standard 0.26), so Altium answers all of it again:+  - `altium_export_pos`: the board's pick-and-place file, each part's reference point from the board origin with its+    rotation and side, as Altium's Pick Place output gives them: CSV or aligned text, mm or inches, one side or both,+    `smdOnly` (parts with a plated hole left out), the not-fitted parts of a named `variant` left out, and JLCPCB's+    CPL beside it with `fab: "jlcpcb"`. A Gerber placement file is refused by name: Altium writes none.+  - `altium_verb_times`: each verb's count, p50, p90, max, last run and failures on this machine, from the bridge's+    own run log, slowest p90 first.+  - `altium_prewarm`: finds the install, writes the agent's script and, with Altium running, answers its first-run+    boxes and makes the agent resident. Idempotent; it never opens a document or launches Altium.+  - `altium_render_board`: the standard's name for `render_board_3d` (Altium's 3D print, no window), top or bottom;+    the camera options Altium cannot apply are named in `optionsNotApplied`.+- **`xcopy_footprint` puts the copy on its origin** (#29). A copy within one library landed 1270 mm off: the shift was+  measured on the source after the copy had taken the display, when Altium reports a footprint's primitives without+  the library's origin. Moving the copy after it was shown did not hold either: Altium shifted it again when the display+  left it and came back. The replicas are now taken from the source while it is on display and made relative to the+  origin, as Altium keeps a footprint that is not shown, and the copy is checked once shown: `copy_misplaced` names the+  pad when it is off. Measured on DESKTOP-BAR6S0F: BAT_FP copied within Battery.PcbLib, and E-8 copied from Altium's+  SpiritLevel example library, each match their source pad for pad across repeated reads with the display moved in+  between. `lint_library` found the bug.+ ## 0.2.84  - **`altium_update_footprints_from_library`: bring placed parts up to the library's footprint.** KiCad's verb, same name
README.md+8−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 -259 commands, tested on Altium Designer 26.11 and Altium Designer Develop. It runs in **Hydrogen**, Adom's free+263 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. 259 verbs; each row names the ones+Tested on Altium Designer 26.11.1 and Altium Designer Develop. 263 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 259 `altium_*` verbs.+**DelphiScript agent** inside it, and gives the AI 263 `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 259 verbs, by area (prefix `altium_`). `altium_describe` returns the live catalog with every input, output, hint and example.+All 263 verbs, by area (prefix `altium_`). `altium_describe` returns the live catalog with every input, output, hint and example.  ### Running Altium: launch, close, health, dialogs @@ -253,6 +253,10 @@ All 259 verbs, by area (prefix `altium_`). `altium_describe` returns the live ca - `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_lint_library`: Check a .PcbLib or .SchLib before it ships: footprints without pads, courtyard, silkscreen or 3D body, with duplicate or missing pad numbers, an origin off the part or no description; symbols without pins or a footprint, with duplicate pin numbers or no part number, and pins that no pad of the linked footprint answers.+- `altium_export_pos`: The board's pick-and-place (component position, CPL) file: each part's reference point from the board origin, its rotation and side, as Altium's Pick Place output gives them; optionally JLCPCB's CPL beside it.+- `altium_verb_times`: Measured run times of this bridge's verbs on this machine: per verb the count, p50, p90, max, last and failures, from its own run log, slowest p90 first.+- `altium_prewarm`: Get this machine ready for a fast first call: find the install, write the agent's script, and with Altium running answer its first-run boxes and make the agent resident.+- `altium_render_board`: A rendered 3D picture of a board from the top or bottom, by Altium's own 3D print with no window (render_board_3d under the standard's name). - `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/main.rs+2−1
@@ -33,6 +33,7 @@ mod coppermap; mod current; mod fpupdate; mod liblint;+mod pos; mod impedance; mod inspect; mod lengths;@@ -70,7 +71,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.84";+pub const BRIDGE_VERSION: &str = "0.2.85";  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/misc.rs+35
@@ -5,6 +5,41 @@ use crate::{ab, agent, dialogs, instance, lifecycle, progress, taskbar}; use serde_json::{json, Value}; use std::time::Duration; +/// altium_prewarm {}: the standard's prewarm (EDA Bridge Standard #29). Idempotent. Never opens a document, never+/// launches Altium (that would put a window in the user's face): with Altium running it answers the first-run boxes+/// the reaper knows and makes the agent resident, which is what the first real verb would otherwise do slowly.+pub fn prewarm(_args: &Value) -> Value {+    let mut steps = Vec::new();+    let inst = support::first_install();+    steps.push(match &inst { Some(i) => json!({"step": "detect", "done": true, "install": i}),+        None => json!({"step": "detect", "done": false, "why": "no Altium Designer or Altium Develop is installed (altium_install)"}) });+    let files = crate::lifecycle::install();+    let files_ok = files.get("installed").and_then(|b| b.as_bool()) == Some(true);+    steps.push(json!({"step": "agent_files", "done": files_ok, "changed": files.get("changed"), "why": files.get("error")}));+    let lic = instance::licence_state();+    let running = lic.get("running").and_then(|b| b.as_bool()).unwrap_or(false);+    let licensed = lic.get("licensed").and_then(|b| b.as_bool()) == Some(true);+    let mut alive = agent::is_alive();+    if !running {+        for s in ["first_run_dialogs", "agent"] {+            steps.push(json!({"step": s, "done": false, "skipped": true, "why": "Altium is not running, and prewarm does not launch it (a launch opens a window on the user's screen); the first verb that needs Altium launches it"}));+        }+    } else {+        let answered = crate::dialogs::reap_once();+        steps.push(json!({"step": "first_run_dialogs", "done": true, "answered": answered}));+        if alive { steps.push(json!({"step": "agent", "done": true, "skipped": true, "why": "already resident"})); }+        else if !licensed { steps.push(json!({"step": "agent", "done": false, "why": format!("Altium is not licensed ({}): scripting is refused (altium_ensure_licensed)", lic.get("state").and_then(|v| v.as_str()).unwrap_or("?"))})); }+        else {+            let r = crate::lifecycle::start(Duration::from_secs(45));+            alive = r.get("success").and_then(|b| b.as_bool()) == Some(true);+            steps.push(json!({"step": "agent", "done": alive, "why": if alive { Value::Null } else { r.get("error").cloned().unwrap_or(json!("the agent did not start")) }}));+        }+    }+    let ready = inst.is_some() && files_ok && (!running || alive);+    json!({"success": true, "ready": ready, "steps": steps, "running": running, "windowEtiquette": "background",+        "_hint": "Run it again any time: a step already done is skipped. ready: installed, the agent's script written, and, with Altium running, the agent resident."})+}+ pub fn readiness(_args: &Value) -> Value {     let inst = support::first_install();     let lic = instance::licence_state();
bridge-rs/src/pos.rsadded+172
@@ -0,0 +1,172 @@+//! export_pos: the board's pick-and-place (component position, CPL) file, the standard's verb (EDA Bridge Standard+//! #29). Positions come from the board itself, from its origin, as Altium's own Pick Place output gives them; parts+//! not fitted in the variant named are left out, as are through-hole parts with smdOnly. JLCPCB's CPL is written+//! beside it on request. Altium's generator writes CSV and text; a Gerber placement file it cannot, so that format+//! is refused by name.+use serde_json::{json, Value};+use std::collections::HashSet;+use std::path::{Path, PathBuf};++/// One placed part, as bom_placement reads it.+#[derive(Clone, Debug, PartialEq)]+pub struct Placed { pub des: String, pub footprint: String, pub x: f64, pub y: f64, pub rot: f64, pub bottom: bool, pub comment: String, pub tht: bool }++pub struct Opts { pub side: String, pub ascii: bool, pub inches: bool, pub smd_only: bool, pub jlcpcb: bool, pub stem: String }++fn csv_cell(s: &str) -> String { if s.contains([',', '"', '\n']) { format!("\"{}\"", s.replace('"', "\"\"")) } else { s.to_string() } }+fn rot(r: f64) -> String { let r = (r.rem_euclid(360.0) * 1000.0).round() / 1000.0; format!("{}", if r >= 360.0 { 0.0 } else { r }) }++/// The parts each file carries, and the files (name, text). Pure.+pub fn files<'a>(parts: &'a [Placed], o: &Opts) -> (Vec<&'a Placed>, Vec<(String, String)>) {+    let mut keep: Vec<&Placed> = parts.iter()+        .filter(|p| match o.side.as_str() { "front" => !p.bottom, "back" => p.bottom, _ => true })+        .filter(|p| !(o.smd_only && p.tht)).collect();+    keep.sort_by_key(|p| crate::bom::natural_key(&p.des));+    let (unit, k, dec) = if o.inches { ("in", 1.0 / 25.4, 4) } else { ("mm", 1.0, 4) };+    let layer = |p: &Placed| if p.bottom { "BottomLayer" } else { "TopLayer" };+    let head = ["Designator", "Comment", "Layer", "Footprint", &format!("Center-X({unit})"), &format!("Center-Y({unit})"), "Rotation"].map(String::from);+    let rows: Vec<[String; 7]> = keep.iter().map(|p| [p.des.clone(), p.comment.clone(), layer(p).into(), p.footprint.clone(),+        format!("{:.dec$}", p.x * k), format!("{:.dec$}", p.y * k), rot(p.rot)]).collect();+    let side = match o.side.as_str() { "front" => "-front", "back" => "-back", _ => "" };+    let mut out = Vec::new();+    if o.ascii {+        // Altium's text output: columns padded to the widest cell+        let all: Vec<&[String; 7]> = std::iter::once(&head).chain(rows.iter()).collect();+        let w: Vec<usize> = (0..7).map(|c| all.iter().map(|r| r[c].chars().count()).max().unwrap_or(0)).collect();+        let mut t = format!("Pick and place, units {unit}, from the board origin\r\n\r\n");+        for r in all { t.push_str(r.iter().enumerate().map(|(c, v)| format!("{v:<w$}", w = w[c])).collect::<Vec<_>>().join("  ").trim_end()); t.push_str("\r\n"); }+        out.push((format!("{}-pos{side}.txt", o.stem), t));+    } else {+        let mut t = head.iter().map(|h| csv_cell(h)).collect::<Vec<_>>().join(",") + "\r\n";+        for r in &rows { t.push_str(&r.iter().map(|c| csv_cell(c)).collect::<Vec<_>>().join(",")); t.push_str("\r\n"); }+        out.push((format!("{}-pos{side}.csv", o.stem), t));+    }+    if o.jlcpcb {+        // JLCPCB's CPL: their headers, mm, Top/Bottom (the same columns altium_bom writes)+        let mut t = String::from("Designator,Mid X,Mid Y,Layer,Rotation\r\n");+        for p in &keep { t.push_str(&format!("{},{:.4}mm,{:.4}mm,{},{}\r\n", csv_cell(&p.des), p.x, p.y, if p.bottom { "Bottom" } else { "Top" }, rot(p.rot))); }+        out.push((format!("{}-cpl-jlcpcb{side}.csv", o.stem), t));+    }+    (keep, out)+}++/// bom_placement's row: [designator, pattern, x, y (raw from the origin), rotation (millidegrees), bottom, comment, tht]+fn placed(c: &Value) -> Placed {+    let mm = |v: &Value| (v.as_f64().unwrap_or(0.0) / 10000.0 * 0.0254 * 10000.0).round() / 10000.0;+    let s = |v: &Value| v.as_str().unwrap_or("").to_string();+    Placed { des: s(&c[0]), footprint: s(&c[1]), x: mm(&c[2]), y: mm(&c[3]), rot: c[4].as_f64().unwrap_or(0.0) / 1000.0,+        bottom: c[5].as_bool() == Some(true), comment: s(&c[6]), tht: c[7].as_bool() == Some(true) }+}++/// The project beside the board that lists it.+fn project_of(board: &Path) -> Option<PathBuf> {+    let dir = board.parent()?;+    let name = board.file_name()?.to_string_lossy().to_lowercase();+    std::fs::read_dir(dir).ok()?.flatten().map(|e| e.path())+        .filter(|p| p.extension().map(|x| x.eq_ignore_ascii_case("PrjPcb")).unwrap_or(false))+        .find(|p| std::fs::read_to_string(p).map(|t| t.to_lowercase().lines().any(|l| l.starts_with("documentpath=") && l.ends_with(&name))).unwrap_or(false))+}++/// altium_export_pos {filePath, side?, format?, units?, smdOnly?, excludeDnp?, variant?, projectPath?, fab?, outputDir?}+pub fn export_pos(args: &Value) -> Value {+    if let Some(g) = crate::support::need_licensed() { return g; }+    let s = |k: &str| crate::support::s(args, k);+    let Some(board) = s("filePath").or_else(|| s("pcbPath")).filter(|p| p.to_lowercase().ends_with(".pcbdoc")) else {+        return json!({"success": false, "errorCode": "bad_args", "error": "filePath (the .PcbDoc) is required"});+    };+    let format = s("format").unwrap_or_else(|| "csv".into()).to_lowercase();+    if format == "gerber" {+        return json!({"success": false, "errorCode": "unsupported", "error": "Altium's Pick Place output writes CSV and text, not a Gerber placement file",+            "_hint": "Ask for format csv (default) or ascii."});+    }+    if format != "csv" && format != "ascii" { return json!({"success": false, "errorCode": "bad_args", "error": format!("format '{format}' is not csv, ascii or gerber")}); }+    let side = s("side").unwrap_or_else(|| "both".into()).to_lowercase();+    if !["both", "front", "back"].contains(&side.as_str()) { return json!({"success": false, "errorCode": "bad_args", "error": "side is both, front or back"}); }+    let units = s("units").unwrap_or_else(|| "mm".into()).to_lowercase();+    if units != "mm" && units != "in" { return json!({"success": false, "errorCode": "bad_args", "error": "units is mm or in"}); }+    let fab = s("fab").map(|f| f.to_lowercase());+    if let Some(f) = fab.as_deref().filter(|f| *f != "jlcpcb") { return json!({"success": false, "errorCode": "bad_args", "error": format!("fab '{f}' is not one this bridge writes (jlcpcb)")}); }+    let b = |k: &str, d: bool| args.get(k).and_then(|v| v.as_bool()).unwrap_or(d);+    if let Some(e) = crate::support::must_open(&board, 60) { return e; }+    let r = crate::agent::call("bom_placement", &[], None, crate::support::timeout_of(args, 120));+    let Some(rows) = r.get("data").filter(|d| d["ok"].as_bool() == Some(true)).and_then(|d| d["comps"].as_array()).cloned() else {+        return json!({"success": false, "errorCode": "board_read_failed", "board": board, "reply": r});+    };+    let all: Vec<Placed> = rows.iter().map(placed).filter(|p| !p.des.is_empty()).collect();+    // not fitted: in the variant named (Altium marks do-not-populate per variant)+    let bpath = PathBuf::from(board.replace('\\', "/"));+    let prj = s("projectPath").map(PathBuf::from).or_else(|| project_of(&bpath));+    let mut dnp: HashSet<String> = HashSet::new();+    let mut variant_used = Value::Null;+    if let Some(v) = s("variant").filter(|v| !v.trim().is_empty() && !v.eq_ignore_ascii_case("none")) {+        let Some(p) = &prj else { return json!({"success": false, "errorCode": "no_project", "error": "a variant needs the board's project: none beside the board lists it (pass projectPath)"}) };+        let text = String::from_utf8_lossy(&std::fs::read(p).unwrap_or_default()).to_string();+        let project = crate::bom::parse_project(&text, p.parent().unwrap_or(Path::new(".")));+        let Some((name, m)) = project.variants.iter().find(|(n, _)| n.eq_ignore_ascii_case(&v)) else {+            return json!({"success": false, "errorCode": "variant_not_found", "error": format!("no variant named {v}"), "variants": project.variants.iter().map(|(n, _)| n.clone()).collect::<Vec<_>>()});+        };+        if b("excludeDnp", true) { dnp = m.iter().filter(|(_, (kind, _))| *kind == 1).map(|(d, _)| d.to_ascii_uppercase()).collect(); }+        variant_used = json!(name);+    }+    let fitted: Vec<Placed> = all.iter().filter(|p| !dnp.contains(&p.des.to_ascii_uppercase())).cloned().collect();+    let stem = bpath.file_stem().map(|x| x.to_string_lossy().to_string()).unwrap_or_else(|| "board".into());+    let opts = Opts { side: side.clone(), ascii: format == "ascii", inches: units == "in", smd_only: b("smdOnly", false), jlcpcb: fab.is_some(), stem };+    let (keep, out) = files(&fitted, &opts);+    let dir = s("outputDir").map(PathBuf::from).unwrap_or_else(|| bpath.parent().unwrap_or(Path::new(".")).join("Pick Place"));+    if let Err(e) = std::fs::create_dir_all(&dir) { return json!({"success": false, "errorCode": "write_failed", "error": format!("{}: {e}", dir.display())}); }+    let mut written = Vec::new();+    for (name, text) in &out {+        let p = dir.join(name);+        if let Err(e) = std::fs::write(&p, text) { return json!({"success": false, "errorCode": "write_failed", "error": format!("{}: {e}", p.display())}); }+        written.push(p.to_string_lossy().replace('/', "\\"));+    }+    let front = keep.iter().filter(|p| !p.bottom).count();+    let mut dnp_left: Vec<String> = all.iter().filter(|p| dnp.contains(&p.des.to_ascii_uppercase())).map(|p| p.des.clone()).collect();+    dnp_left.sort_by_key(|d| crate::bom::natural_key(d));+    let tht_left: Vec<String> = if opts.smd_only { fitted.iter().filter(|p| p.tht).map(|p| p.des.clone()).collect() } else { vec![] };+    json!({"success": true, "files": written, "parts": {"front": front, "back": keep.len() - front, "total": keep.len()},+        "excluded": {"dnp": dnp_left, "throughHole": tht_left}, "variant": variant_used, "units": units, "format": format, "side": side,+        "_hint": "Positions are each part's reference point from the board origin, as Altium's own Pick Place output gives them. DNP is per variant in Altium: name the variant to leave its not-fitted parts out. Check rotations in the assembler's preview (JLCPCB's package orientation can differ from Altium's)."})+}++#[cfg(test)]+mod tests {+    use super::*;++    fn p(d: &str, x: f64, y: f64, r: f64, bottom: bool, tht: bool) -> Placed {+        Placed { des: d.into(), footprint: "FP".into(), x, y, rot: r, bottom, comment: "10k, 1%".into(), tht }+    }++    #[test]+    fn csv_both_sides_in_designator_order() {+        let parts = vec![p("R10", 1.0, 2.0, 90.0, false, false), p("R2", 3.0, 4.0, -90.0, true, false), p("J1", 5.0, 6.0, 0.0, false, true)];+        let o = Opts { side: "both".into(), ascii: false, inches: false, smd_only: false, jlcpcb: true, stem: "b".into() };+        let (keep, out) = files(&parts, &o);+        assert_eq!(keep.iter().map(|p| p.des.as_str()).collect::<Vec<_>>(), ["J1", "R2", "R10"]);+        assert_eq!(out[0].0, "b-pos.csv");+        let lines: Vec<&str> = out[0].1.lines().collect();+        assert_eq!(lines[0], "Designator,Comment,Layer,Footprint,Center-X(mm),Center-Y(mm),Rotation");+        assert_eq!(lines[2], "R2,\"10k, 1%\",BottomLayer,FP,3.0000,4.0000,270");+        assert_eq!(out[1].0, "b-cpl-jlcpcb.csv");+        assert!(out[1].1.contains("R10,1.0000mm,2.0000mm,Top,90"));+    }++    #[test]+    fn a_side_smd_only_and_inches() {+        let parts = vec![p("U1", 25.4, 0.0, 0.0, false, false), p("J1", 0.0, 0.0, 0.0, false, true), p("C1", 0.0, 0.0, 0.0, true, false)];+        let o = Opts { side: "front".into(), ascii: false, inches: true, smd_only: true, jlcpcb: false, stem: "b".into() };+        let (keep, out) = files(&parts, &o);+        assert_eq!(keep.len(), 1);+        assert_eq!(out.len(), 1);+        assert_eq!(out[0].0, "b-pos-front.csv");+        assert!(out[0].1.contains("U1,\"10k, 1%\",TopLayer,FP,1.0000,0.0000,0"), "{}", out[0].1);+    }++    #[test]+    fn ascii_is_aligned() {+        let o = Opts { side: "both".into(), ascii: true, inches: false, smd_only: false, jlcpcb: false, stem: "b".into() };+        let (_, out) = files(&[p("U1", 1.0, 2.0, 0.0, false, false)], &o);+        assert_eq!(out[0].0, "b-pos.txt");+        assert!(out[0].1.contains("Designator  Comment  Layer     Footprint  Center-X(mm)  Center-Y(mm)  Rotation\r\nU1          10k, 1%  TopLayer  FP         1.0000"), "{}", out[0].1);+    }+}
bridge-rs/src/progress.rs+48
@@ -348,10 +348,58 @@ pub fn verb_report(limit: usize) -> Value {     Value::Object(out) } +/// The standard's verb_times (EDA Bridge Standard #29) from the run log's text: per verb count, p50, p90, max, the+/// last run and failures, slowest p90 first, and when the log starts. Pure.+pub fn verb_times_of(raw: &str, limit: usize) -> Value {+    let mut runs: BTreeMap<String, (Vec<f64>, f64, u64)> = BTreeMap::new();+    let mut since: Option<i64> = None;+    for line in raw.lines() {+        let Ok(r) = serde_json::from_str::<Value>(line) else { continue };+        let verb = r.get("verb").and_then(|v| v.as_str()).unwrap_or("?").to_string();+        let secs = r.get("seconds").and_then(|s| s.as_f64()).unwrap_or(0.0);+        if let Some(at) = r.get("at").and_then(|a| a.as_i64()) { since = Some(since.map_or(at, |s| s.min(at))); }+        let e = runs.entry(verb).or_default();+        e.0.push(secs);+        e.1 = secs;+        if r.get("ok").and_then(|b| b.as_bool()) != Some(true) { e.2 += 1; }+    }+    let r2 = |v: f64| (v * 100.0).round() / 100.0;+    let mut rows: Vec<Value> = runs.into_iter().map(|(verb, (secs, last, fails))| json!({"verb": verb, "count": secs.len(),+        "p50Sec": r2(pct(&secs, 0.5)), "p90Sec": r2(pct(&secs, 0.9)), "maxSec": r2(secs.iter().cloned().fold(0.0, f64::max)), "lastSec": r2(last), "failures": fails})).collect();+    rows.sort_by(|a, b| b["p90Sec"].as_f64().partial_cmp(&a["p90Sec"].as_f64()).unwrap_or(std::cmp::Ordering::Equal));+    rows.truncate(limit);+    json!({"verbs": rows, "since": since})+}++/// altium_verb_times {limit?}+pub fn verb_times(args: &Value) -> Value {+    let limit = args.get("limit").and_then(|v| v.as_u64()).unwrap_or(40) as usize;+    // the current log and the one it rolled over from, oldest first+    let p = runlog_path();+    let text = [p.with_extension("jsonl.1"), p.clone()].iter().filter_map(|f| std::fs::read_to_string(f).ok()).collect::<Vec<_>>().join("\n");+    let mut r = verb_times_of(&text, limit);+    r["success"] = json!(true);+    r["log"] = json!(p.to_string_lossy());+    r["_hint"] = json!("Times are this machine's, from every verb this bridge ran here (since is when the log starts, Unix seconds). p90 is the headline: a p50 of 15 s beside a p90 of 400 s is two code paths under one name.");+    r+}+ #[cfg(test)] mod tests {     use super::*; +    #[test]+    fn verb_times_from_the_log() {+        let log = "{\"at\":100,\"verb\":\"run_drc\",\"seconds\":8.0,\"ok\":true}\n{\"at\":90,\"verb\":\"run_drc\",\"seconds\":12.0,\"ok\":false}\nnot json\n{\"at\":110,\"verb\":\"status\",\"seconds\":0.1,\"ok\":true}";+        let r = verb_times_of(log, 40);+        assert_eq!(r["since"], json!(90));+        assert_eq!(r["verbs"][0]["verb"], "run_drc");+        assert_eq!(r["verbs"][0]["count"], 2);+        assert_eq!(r["verbs"][0]["failures"], 1);+        assert_eq!(r["verbs"][0]["lastSec"], json!(12.0));+        assert_eq!(verb_times_of(log, 1)["verbs"].as_array().unwrap().len(), 1);+    }+     #[test]     fn percentile_and_estimate_ladder() {         assert_eq!(pct(&[3.0, 1.0, 2.0], 0.5), 2.0);
bridge-rs/src/render.rs+14
@@ -54,6 +54,20 @@ pub fn render_board_3d(args: &Value) -> Value {         "_hint": "Altium's own PCB 3D Print (its Assembly template's settings, looking straight down or up), printed to PDF and rendered by Windows: no window opens. Parts with no 3D body show as bare pads (altium_bodies lists them)."}) } +/// altium_render_board: the standard's render_board (EDA Bridge Standard #29), through render_board_3d (Altium's own+/// 3D print, no window). Altium looks straight down or up only, so left, right, front and back are refused by name,+/// and the camera options it has no way to apply are named in optionsNotApplied.+pub fn render_board(args: &Value) -> Value {+    let mut r = render_board_3d(args);+    if r.get("success").and_then(|b| b.as_bool()) != Some(true) { return r; }+    r["path"] = r["image"].clone();+    let mut ignored: Vec<String> = r["optionsNotApplied"].as_array().cloned().unwrap_or_default().iter().filter_map(|v| v.as_str().map(str::to_string)).collect();+    for k in ["refs", "marginMm", "rotate"] { if args.get(k).is_some() { ignored.push(k.to_string()); } }+    r["optionsNotApplied"] = json!(ignored);+    if args.get("refs").is_some() { r["framed"] = Value::Null; }+    r+}+ /// The presets: name, what it shows, and Altium's print layers. Pure. pub fn presets() -> Vec<(&'static str, &'static str, Vec<&'static str>)> {     vec![
bridge-rs/src/verbs.rs+25−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", "update_footprints_from_library", "lint_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",+    "routing_state", "route_net", "plan_route", "move_parts", "place_decoupling", "plan_fanout", "estimate_cost", "simulate", "export_spice", "update_footprints_from_library", "lint_library", "export_pos", "verb_times", "prewarm", "render_board", "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",@@ -447,6 +447,26 @@ fn describe() -> Value {             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("verb_times", "Measured run times of this bridge's verbs on this machine: per verb the count, p50, p90, max, last and failures, from its own run log, slowest p90 first.",+            json!({"limit": "int, default 40: how many verbs"}),+            json!({"verbs": "[{verb, count, p50Sec, p90Sec, maxSec, lastSec, failures}]", "since": "Unix seconds: when the log starts", "log": "the log file"}), 15,+            "p90 is the headline: a p50 of 15 s beside a p90 of 400 s is two code paths under one name. failures counts runs that answered success:false.",+            &["diagnostics", "progress"], &["Times are this machine's: a slower box or a bigger board moves them."], json!({"limit": 10})),+        verb_doc("prewarm", "Get this machine ready for a fast first call: find the install, write the agent's script, and with Altium running answer its first-run boxes and make the agent resident. Idempotent; never opens a document or launches Altium.",+            json!({}),+            json!({"ready": "bool", "steps": "[{step: detect | agent_files | first_run_dialogs | agent, done, skipped?, why?}]", "running": "bool"}), 120,+            "The bridge host may run it after an install or update; running it again changes nothing that is already done.",+            &["readiness", "agent_start", "launch"], &["With Altium closed it only detects and writes the agent: the first verb that needs Altium still launches it."], json!({})),+        verb_doc("render_board", "A rendered 3D picture of a board from the top or bottom, by Altium's own 3D print with no window (render_board_3d under the standard's name).",+            json!({"filePath": "the .PcbDoc (required)", "side": "top | bottom (left, right, front and back are refused: Altium's 3D print looks straight down or up)", "width": "px, default 1600", "outputDir": "folder"}),+            json!({"path": "the PNG", "width": "px", "height": "px", "optionsNotApplied": "[the standard's options Altium has no way to apply: height, quality, background, zoom, perspective, format, refs, marginMm, rotate]"}), 300,+            "The picture is of the board as saved in its project. One call per side for a review.",+            &["render_board_3d", "show_3d_board", "render_board_layers"], &["Parts with no 3D body show as bare pads (altium_bodies lists them).", "No framing on parts and no turned view: altium_show_3d_board opens a window for that."], json!({"filePath": "C:/proj/Board.PcbDoc", "side": "top"})),+        verb_doc("export_pos", "The board's pick-and-place (component position, CPL) file: each part's reference point from the board origin, its rotation and side, as Altium's Pick Place output gives them; optionally JLCPCB's CPL beside it.",+            json!({"filePath": "the .PcbDoc (required)", "side": "both | front | back, default both", "format": "csv | ascii (default csv); gerber is refused: Altium writes no Gerber placement file", "units": "mm | in, default mm", "smdOnly": "bool: leave out parts with a plated hole", "excludeDnp": "bool, default true: leave out parts not fitted in the variant", "variant": "the project variant whose not-fitted parts are left out (Altium marks DNP per variant)", "projectPath": "the .PrjPcb (default the project beside the board that lists it)", "fab": "jlcpcb: also write JLCPCB's CPL columns", "outputDir": "folder (default 'Pick Place' beside the board)"}),+            json!({"files": "[path]", "parts": "{front, back, total}", "excluded": "{dnp: [ref], throughHole: [ref]}", "variant": "the variant used or null"}), 120,+            "Pair it with altium_bom (JLCPCB BOM) and the Gerbers for an assembly order; altium_export_manufacturing writes all three from an OutJob. Read: nothing on the board changes.",+            &["export_manufacturing", "bom", "assembly_check", "jlcpcb_order"], &["Rotations follow Altium's convention: a fab may turn some packages; check its preview.", "DNP is per variant in Altium: with no variant every part is fitted."], json!({"filePath": "C:/proj/Board.PcbDoc", "fab": "jlcpcb"})),         verb_doc("lint_library", "Check a .PcbLib or .SchLib before it ships: footprints without pads, courtyard, silkscreen or 3D body, with duplicate or missing pad numbers, an origin off the part or no description; symbols without pins or a footprint, with duplicate pin numbers or no part number, and pins that no pad of the linked footprint answers. KiCad's verb of the same name (KiCad's checks that the file parses; an Altium library always does, so this one checks what is in it).",             json!({"libraryPath": "the .PcbLib or .SchLib (required; filePath accepted too)", "names": "[name] (default every footprint or symbol)", "footprintLibraries": "[.PcbLib] for a SchLib: where the linked footprints are (default the .PcbLibs in the SchLib's folder); footprintLibrary for one"}),             json!({"ok": "bool: no errors and every item read", "checked": "int", "errors": "int", "warnings": "int", "infos": "int", "findings": "[{name, kind: footprint|symbol, rule, severity: error|warning|info, detail}]", "unread": "[{name, error}]", "footprintLibraries": "[path] (SchLib)"}), 600,@@ -2190,6 +2210,10 @@ pub fn dispatch(command: &str, args: &Value, _forwarded: &[(String, String)]) ->         "swap_footprint" => library::swap_footprint(args),         "update_footprints_from_library" => crate::fpupdate::update_footprints_from_library(args),         "lint_library" => crate::liblint::lint_library(args),+        "export_pos" => crate::pos::export_pos(args),+        "verb_times" => progress::verb_times(args),+        "prewarm" => misc::prewarm(args),+        "render_board" => crate::render::render_board(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+17−2
@@ -95,6 +95,8 @@ def matrix(w):               "a365_oauth_status"]:         M[v] = dict(phase=0, **ok())     M["dialog_log"] = dict(phase=0, **ok(limit=5))+    # 0.2.85: the standard's verb_times, from this machine's run log (every earlier battery wrote to it)+    M["verb_times"] = dict(phase=0, **ok(limit=5), check=lambda d: 0 < len(d.get("verbs") or []) <= 5 and "p90Sec" in (d.get("verbs") or [{}])[0])     M["install"] = dict(phase=0, **ok(stage="preflight"), note="read-only stage: disk, OS, elevation, UAC policy. Never launches an installer")     M["list_commands"] = dict(phase=0, **ok(query="PCB", limit=5))     M["uninstall"] = dict(phase=0, **ok(dryRun=True), note="SAFETY: dryRun only, never removes anything")@@ -108,6 +110,9 @@ def matrix(w):     # ---- phase 1: lifecycle ------------------------------------------------------------------     M["launch"] = dict(phase=1, timeout=300, **ok(waitSec=150))     M["agent_start"] = dict(phase=1, **ok())+    # 0.2.85: the standard's prewarm, with Altium up and the agent resident: idempotent, ready, nothing opened+    M["prewarm"] = dict(phase=1, timeout=150, **ok(), check=lambda d: d.get("ready") is True+                        and any(x.get("step") == "agent" and x.get("done") for x in d.get("steps") or []))     M["ensure_licensed"] = dict(phase=1, timeout=300, **ok(), note="defaults only: never signs out, never starts a trial")     M["state"] = dict(phase=1, **ok(screenshots=False))     M["eval"] = dict(phase=1, **ok(text="Begin End;"))@@ -159,7 +164,12 @@ def matrix(w):     M["copy_footprint"] = dict(phase=2, **ok(libraryPath=PL, **{"from": "BAT_FP", "to": "BAT_FP_COPY"}))     M["rename_footprint"] = dict(phase=2, **ok(libraryPath=PL, **{"from": "BAT_FP_COPY", "to": "BAT_FP_RENAMED"}))     M["remove_footprint"] = dict(phase=2, **ok(libraryPath=PL, footprintName="BAT_FP_RENAMED"))-    M["xcopy_footprint"] = dict(phase=2, **anyo("cross-library copy onto itself: ok or named refusal", fromLib=PL, toLib=PL, **{"from": "BAT_FP", "to": "BAT_FP_X"}))+    # 0.2.85: the copy checks itself on display (copy_misplaced when a pad is off): it landed 1270 mm off before (#29).+    # Regression: lint_library on the copy must not find its origin off the part+    lint_origin = lambda name: [f for f in (w["call"]("altium_lint_library", {"libraryPath": PL, "names": [name]}).get("findings") or [])+                                if f.get("rule") == "origin_off_part"]+    M["xcopy_footprint"] = dict(phase=2, **ok(fromLib=PL, toLib=PL, **{"from": "BAT_FP", "to": "BAT_FP_X"}),+                                check=lambda d: (d.get("data") or d).get("ok") is True and lint_origin("BAT_FP_X") == [])     M["add_body"] = dict(phase=2, **anyo("extruded body on the scratch footprint", libraryPath=PL, footprintName="BAT_FP", hMil=40))     M["edit_footprint"] = dict(phase=2.5, **ok(libraryPath=PL, name="BAT_FP", addPads=[{"number": "99", "at": [5, 5], "sizeMm": [0.5, 0.5]}],                                metadata={"description": "edited by the battery"}),@@ -221,6 +231,9 @@ def matrix(w):                                                         parts=lane_parts, nets=lane_nets),                             check=lambda d: d.get("placed") == 2 and not d.get("wrongPins"))     M["routing_state"] = dict(phase=3.5, **ok(expectPath=LB), check=lambda d: n_comps(d) == 2)+    # 0.2.85: the standard's export_pos on the lane board just built: both SOICs, the CSV and JLCPCB's CPL+    M["export_pos"] = dict(phase=3.5, **ok(filePath=LB, fab="jlcpcb"),+                           check=lambda d: (d.get("parts") or {}).get("total") == 2 and len(d.get("files") or []) == 2)     # 0.2.58: the stack-up of the board just built (2 copper layers)     M["layer_stack"] = dict(phase=3.5, **ok(), check=lambda d: (d.get("data") or {}).get("copperLayers") == 2)     M["set_design_rules"] = dict(phase=3.5, timeout=300, **ok(clearance=0.2, trackWidth={"min": 0.15, "preferred": 0.25, "max": 2},@@ -430,6 +443,7 @@ def matrix(w):     M["project_rename"] = dict(phase=3.5, **ok(project=D + "/NewProj/NewProj.PrjPcb", newName="NewProj2", dryRun=True), check=lambda d: len(d.get("renamed") or []) == 3)     M["project_snapshot"] = dict(phase=3.5, **ok(project=LP, label="battery", pdfs=False), check=lambda d: len(d.get("files") or []) >= 3)     M["render_board_3d"] = dict(phase=3.5, timeout=700, **anyo("a 3D picture of the lane board, or a named refusal", filePath=LB, width=800))+    M["render_board"] = dict(phase=3.5, timeout=700, **anyo("the standard's name for render_board_3d: a picture or a named refusal", filePath=LB, side="top", width=800))     M["render_board_layers"] = dict(phase=3.5, timeout=700, **ok(filePath=LB, preset="top_copper", dpi=100), check=lambda d: str(d.get("path", "")).endswith(".png"))     M["library_views"] = dict(phase=3.5, timeout=600, **anyo("symbol and footprint pictures of TST_SOIC8", libraryPath=SL, parts=["TST_SOIC8"], views=["symbol", "footprint"]))     M["export_library_part"] = dict(phase=3.5, timeout=600, **anyo("the symbol and footprint in their own libraries, model missing named", part="TST_SOIC8", libraryPath=SL, outputDir=D + "/export"))@@ -586,7 +600,8 @@ def main():     if r.get("stdout"):         home = r["stdout"].strip().replace("\\", "/")     D = home + "/Documents/Adom/altium-bridge-battery"-    w = dict(dir=D, schlib=D + "/Battery.SchLib", pcblib=D + "/Battery.PcbLib", schdoc=D + "/battery.SchDoc", pcbdoc=D + "/battery.PcbDoc")+    w = dict(dir=D, schlib=D + "/Battery.SchLib", pcblib=D + "/Battery.PcbLib", schdoc=D + "/battery.SchDoc", pcbdoc=D + "/battery.PcbDoc",+             call=lambda verb, args: ab(T, TH, verb, args))  # a check that needs a second verb's answer      # fixtures -> scratch copies on the target     fx = [os.path.join(a.fixtures, n) for n in ("Adom_Test.SchLib", "Adom_Test.PcbLib")]
package.json+8−2
@@ -1,6 +1,6 @@ {   "slug": "altium-bridge",-  "version": "0.2.84",+  "version": "0.2.85",   "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": [@@ -265,7 +265,13 @@     "replace placed footprints with the library version",     "lint my altium library",     "check an altium library before i ship it",-    "does every symbol pin have a pad altium"+    "does every symbol pin have a pad altium",+    "export pick and place from altium",+    "altium cpl file for jlcpcb",+    "altium centroid file",+    "how long do altium verbs take",+    "prewarm the altium bridge",+    "render my altium board"   ],   "discovery_pitch": "An AI that runs Altium Designer in the user's own session: libraries, schematics, Update PCB, stack-up, routing, DRC, Gerbers and BOMs.",   "sample_prompts": [
page.json+8−2
@@ -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.84",+  "version": "0.2.85",   "hero": {     "type": "image",     "path": "screenshots/hero.png"@@ -257,7 +257,13 @@     "replace placed footprints with the library version",     "lint my altium library",     "check an altium library before i ship it",-    "does every symbol pin have a pad altium"+    "does every symbol pin have a pad altium",+    "export pick and place from altium",+    "altium cpl file for jlcpcb",+    "altium centroid file",+    "how long do altium verbs take",+    "prewarm the altium bridge",+    "render my altium board"   ],   "discovery_pitch": "An AI that runs Altium Designer in the user's own session: libraries, schematics, Update PCB, stack-up, routing, DRC, Gerbers and BOMs.",   "metadata": {},
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-0.2.84+0.2.85
src/agent/AdomAgent.pas.tmpl+35−23
@@ -4464,9 +4464,9 @@ Var     GIt  : IPCB_GroupIterator;     Prim, Cpy : IPCB_Primitive;     SP, DP : IPCB_Pad;-    NCopied, DX, DY : Integer;+    NCopied, SX, SY : Integer;     Dflt : IPCB_LibComponent;-    Dropped : String;+    Dropped, PN : String; Begin     DstLib := PCBServer.GetCurrentPCBLibrary;     If DstLib = Nil Then@@ -4491,6 +4491,13 @@ Begin         Result := '{' + JRaw('ok','false') + ',' + JStr('error','target already exists: ' + Param(Lines, 'to')) + '}';         Exit;     End;+    { the source's first pad, from its origin, read while the source is the footprint on display: only that one sits+      on the library's origin (lib_fp reads the same way) }+    If SrcLib.CurrentComponent <> Src Then Begin SrcLib.CurrentComponent := Src; SrcLib.Board.ViewManager_FullUpdate; End;+    { one pad, named once: the order Altium walks a footprint's pads in changes when the display moves }+    PN := FirstPadName(Src);+    SP := FpPad(Src, PN);+    If SP <> Nil Then Begin SX := SP.X - SrcLib.Board.XOrigin; SY := SP.Y - SrcLib.Board.YOrigin; End;     PCBServer.PreProcess;     Dst := PCBServer.CreatePCBLibComp;     Dst.Name := Param(Lines, 'to');@@ -4502,32 +4509,19 @@ Begin     While Prim <> Nil Do     Begin         Cpy := Prim.Replicate;+        { the source is on display, so its primitives sit on the library's origin; a footprint not on display keeps+          them from the origin itself, and Altium puts it back on the origin when it is shown }+        Cpy.MoveByXY(-SrcLib.Board.XOrigin, -SrcLib.Board.YOrigin);         Dst.AddPCBObject(Cpy);         NCopied := NCopied + 1;         Prim := GIt.NextPCBObject;     End;     Src.GroupIterator_Destroy(GIt);     DstLib.RegisterComponent(Dst);-    { the copy sits where the source sat on ITS library's origin: a pad keeps its place from the origin. A library's-      origin read from a library not on display was stale (the copy landed 1270 mm off, 2026-10-28), so both-      footprints are shown first and the shift is measured on a pad. }-    SrcLib.CurrentComponent := Src;-    DstLib.CurrentComponent := Dst;-    SP := FpPad(Src, FirstPadName(Src));-    DP := FpPad(Dst, FirstPadName(Src));-    If (SP <> Nil) And (DP <> Nil) Then-    Begin-        DX := (SP.X - SrcLib.Board.XOrigin) - (DP.X - DstLib.Board.XOrigin);-        DY := (SP.Y - SrcLib.Board.YOrigin) - (DP.Y - DstLib.Board.YOrigin);-        If (DX <> 0) Or (DY <> 0) Then-        Begin-            GIt := Dst.GroupIterator_Create;-            GIt.AddFilter_LayerSet(AllLayers);-            Prim := GIt.FirstPCBObject;-            While Prim <> Nil Do Begin Prim.MoveByXY(DX, DY); Prim := GIt.NextPCBObject; End;-            Dst.GroupIterator_Destroy(GIt);-        End;-    End;+    { Moving the copy while it is on display does not hold: Altium shifted it again when the display left it and came+      back (the copy landed one origin, 1270 mm, off, then 6 mm off: altium-bridge#29, 2026-10-30). The replicas are+      made from the origin instead, above, and the copy is checked once shown. }+    DstLib.CurrentComponent := Dst; DstLib.Board.ViewManager_FullUpdate;     { a PcbLib Altium has just made holds an empty PCBComponent_1: it goes once a real footprint is in }     Dropped := '';     Dflt := FindFp(DstLib, 'PCBComponent_1');@@ -4538,6 +4532,14 @@ Begin     End;     PCBServer.PostProcess;     DstLib.Board.ViewManager_FullUpdate;+    { read back on display: the copy's first pad must sit where the source's does }+    DP := FpPad(Dst, PN);+    If (SP <> Nil) And (DP <> Nil) And (DstLib.CurrentComponent = Dst) Then+        If (DP.X - DstLib.Board.XOrigin <> SX) Or (DP.Y - DstLib.Board.YOrigin <> SY) Then+        Begin+            Result := '{' + JRaw('ok','false') + ',' + JStr('errorCode','copy_misplaced') + ',' + JStr('error', 'the copy of ' + Src.Name + ' landed off its origin: pad ' + DP.Name + ' at ' + IntToStr(DP.X - DstLib.Board.XOrigin) + ',' + IntToStr(DP.Y - DstLib.Board.YOrigin) + ' where the source has ' + IntToStr(SX) + ',' + IntToStr(SY) + ' (internal units)') + '}';+            Exit;+        End;     Result := '{' + JRaw('ok','true') + ',' + JStr('to', Dst.Name) + ',' + JRaw('primitives', IntToStr(NCopied)) + ',' + JStr('removedDefault', Dropped) + '}'; End; @@ -4620,8 +4622,11 @@ Var     Board : IPCB_Board;     BIt   : IPCB_BoardIterator;     Comp  : IPCB_Component;+    GIt   : IPCB_GroupIterator;+    Pad   : IPCB_Pad;     S     : String;     N     : Integer;+    Tht   : Boolean; Begin     Board := PCBServer.GetCurrentPCBBoard;     If Board = Nil Then Begin Result := '{' + JRaw('ok','false') + ',' + JStr('error','no current PCB board (open a .PcbDoc first)') + '}'; Exit; End;@@ -4633,10 +4638,17 @@ Begin     Comp := BIt.FirstPCBObject;     While Comp <> Nil Do     Begin+        { through-hole: any pad with a hole (export_pos's smdOnly leaves these out) }+        Tht := False;+        GIt := Comp.GroupIterator_Create;+        GIt.AddFilter_ObjectSet(MkSet(ePadObject));+        Pad := GIt.FirstPCBObject;+        While (Pad <> Nil) And (Not Tht) Do Begin If Pad.HoleSize > 0 Then Tht := True; Pad := GIt.NextPCBObject; End;+        Comp.GroupIterator_Destroy(GIt);         If S <> '' Then S := S + ',';         S := S + '[' + '"' + JsonEsc(Comp.Name.Text) + '","' + JsonEsc(Comp.Pattern) + '",' +             IntToStr(Comp.x - Board.XOrigin) + ',' + IntToStr(Comp.y - Board.YOrigin) + ',' +-            IntToStr(Round(Comp.Rotation * 1000)) + ',' + JBool(Comp.Layer = eBottomLayer) + ']';+            IntToStr(Round(Comp.Rotation * 1000)) + ',' + JBool(Comp.Layer = eBottomLayer) + ',"' + JsonEsc(Comp.Comment.Text) + '",' + JBool(Tht) + ']';         N := N + 1;         Comp := BIt.NextPCBObject;     End;
src/bridge.json+6−2
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "altium",   "displayName": "Altium Designer",-  "version": "0.2.84",+  "version": "0.2.85",   "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",@@ -198,6 +198,10 @@     "altium_export_spice",     "altium_update_footprints_from_library",     "altium_lint_library",+    "altium_export_pos",+    "altium_verb_times",+    "altium_prewarm",+    "altium_render_board",     "altium_route_pair",     "altium_routing_drc",     "altium_routing_state",@@ -291,7 +295,7 @@       "launch": 240,       "panelize": 240,       "impedance": 120,-      "current_capacity": 120, "plan_route": 300, "place_decoupling": 300, "plan_fanout": 300, "estimate_cost": 120, "simulate": 900, "export_spice": 900, "update_footprints_from_library": 600, "lint_library": 600,+      "current_capacity": 120, "plan_route": 300, "place_decoupling": 300, "plan_fanout": 300, "estimate_cost": 120, "simulate": 900, "export_spice": 900, "update_footprints_from_library": 600, "lint_library": 600, "export_pos": 120, "verb_times": 15, "prewarm": 120, "render_board": 300,       "height_check": 150,       "copper_balance": 240,       "return_path": 240,