by adom
Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.
← Commit history
0.2.112: footprint reads see AD 24+ typed component layers (#41); agent lint for use-before-declaration and reserved names
12 files changed
+251−32
CHANGELOG.md+8@@ -1,5 +1,13 @@ # Changelog +## 0.2.112++- **Footprint reads see the typed component layers of Altium Designer 24+** (#41). Top Assembly, Top Courtyard, Top Component Outline, Top Component Center, Top Designator, Top 3D Body and their bottom pairs are mechanical layers above Mechanical 16, and the reads asked Altium only for the first 16: a footprint drawn on them read as a pad and a silkscreen dot. `altium_read_footprint` and `altium_footprint_primitives` now read every layer.+- Each layer comes back by the name Altium shows (`graphics`, and a placed part's `primitives[].layer`). `layerDetails` gives each layer's id, name and kind (`CourtyardTop`, `AssemblyTop`, `DesignatorTop`, `3DBodyTop`, ...), and `altium_read_footprint` lists the footprint's texts (`texts`: the `.Designator` string and its box). Silkscreen is `F.SilkS` instead of `L33`.+- `courtyardMm` is the extent of a Top Courtyard layer's graphics when the footprint has one, else Mechanical 15's as before.+- Placing or copying a footprint still drops graphics on those layers. That is next, with how a board numbers its typed layers.+- Tested on Altium Designer 26.11.1 and Altium Designer Develop with the reporter's template footprint: five typed layers, their kinds, the designator text and the courtyard read back; a footprint on Mechanical 13 and 15 reads as before.+ ## 0.2.111 - **`altium_routing_drc` explains pours shorted to holes with no copper** (`holeClearance`). Since Altium Designer 24 a hole with no copper ring (pad no larger than its hole, no net) no longer gets an implied ring that kept pours away. A board made in an older Altium has a Clearance rule whose Hole row is 0, so after any repour, Altium's own included, the pours run up to such holes and DRC reports shorts. The reply now names the cause and Altium's two fixes: set the Clearance rule's Hole row against copper, or turn off `PCB.Rules.HoleClearance` and restart Altium, then repour.
bridge-rs/src/fplayers.rsadded+108@@ -0,0 +1,108 @@+//! Footprint layers as the reads report them (#41). Since Altium Designer 24 a footprint can be drawn on typed+//! component layers (Top Assembly, Top Courtyard, Top Designator, Top 3D Body, ...): mechanical layers, usually above+//! Mechanical 16, that carry a kind. The agent sends each layer a footprint uses as `[id, name, kind]`, with the name+//! the user sees in Altium and the kind number (-1 for a layer that is not mechanical, 0 for a mechanical layer with+//! no kind). Pure.+use serde_json::{json, Value};++/// A mechanical layer's kind by Altium's number, in the words of its layer type (`CourtyardTop`, `3DBodyTop`).+/// 1, 2, 7 to 14, 16, 17 and 26 to 28 were read from a real library on AD 26.11; the rest follow Altium's file format.+pub fn kind_name(k: i64) -> Option<&'static str> {+ Some(match k {+ 1 => "AssemblyTop", 2 => "AssemblyBottom", 3 => "AssemblyNotes", 4 => "Board",+ 5 => "CoatingTop", 6 => "CoatingBottom", 7 => "ComponentCenterTop", 8 => "ComponentCenterBottom",+ 9 => "ComponentOutlineTop", 10 => "ComponentOutlineBottom", 11 => "CourtyardTop", 12 => "CourtyardBottom",+ 13 => "DesignatorTop", 14 => "DesignatorBottom", 15 => "Dimensions", 16 => "DimensionsTop", 17 => "DimensionsBottom",+ 18 => "FabNotes", 19 => "GluePointsTop", 20 => "GluePointsBottom", 21 => "GoldPlatingTop", 22 => "GoldPlatingBottom",+ 23 => "ValueTop", 24 => "ValueBottom", 25 => "VCut", 26 => "3DBodyTop", 27 => "3DBodyBottom", 28 => "RouteToolPath",+ 29 => "Sheet", 30 => "BoardShape",+ _ => return None,+ })+}++/// One layer the footprint uses.+#[derive(Clone, Debug, PartialEq)]+pub struct Layer {+ pub id: i64,+ pub name: String,+ pub kind: Option<&'static str>,+}++/// The agent's `[[id, name, kind], ...]` rows.+pub fn table(rows: &Value) -> Vec<Layer> {+ rows.as_array().map(|a| a.iter().filter_map(|r| Some(Layer {+ id: r.get(0)?.as_i64()?,+ name: r.get(1).and_then(|v| v.as_str()).unwrap_or("").to_string(),+ kind: kind_name(r.get(2).and_then(|v| v.as_i64()).unwrap_or(-1)),+ })).collect()).unwrap_or_default()+}++/// The name a footprint read gives a layer: the standard's name for copper, silkscreen, paste and mask (as+/// altium_edit_footprint takes them), else the name the user sees in Altium ("Top Courtyard", "Mechanical 15"),+/// else the board model's name.+pub fn display_name(id: i64, layers: &[Layer]) -> String {+ let std = match id {+ 1 => "F.Cu", 32 => "B.Cu", 33 => "F.SilkS", 34 => "B.SilkS", 35 => "F.Paste", 36 => "B.Paste", 37 => "F.Mask", 38 => "B.Mask", 74 => "*.Cu",+ _ => "",+ };+ if !std.is_empty() { return std.to_string(); }+ layers.iter().find(|l| l.id == id && !l.name.is_empty()).map(|l| l.name.clone()).unwrap_or_else(|| crate::routing::layer_name(id))+}++/// The layers that hold the courtyard, best first: a Courtyard Top kind, then Courtyard Bottom, then Mechanical 15+/// (id 71, where this bridge and the IPC wizards put it), then a layer named for a courtyard.+pub fn courtyard_layers(layers: &[Layer]) -> Vec<i64> {+ for want in [Some("CourtyardTop"), Some("CourtyardBottom")] {+ let ids: Vec<i64> = layers.iter().filter(|l| l.kind == want).map(|l| l.id).collect();+ if !ids.is_empty() { return ids; }+ }+ if layers.iter().any(|l| l.id == 71) || layers.is_empty() { return vec![71]; }+ layers.iter().filter(|l| l.name.to_lowercase().contains("courtyard")).map(|l| l.id).collect()+}++/// The reply's layer list: each layer's id, name, kind and how many graphics are on it.+pub fn details(layers: &[Layer], graphics_on: impl Fn(i64) -> usize) -> Vec<Value> {+ layers.iter().map(|l| {+ let mut v = json!({"id": l.id, "name": display_name(l.id, layers), "altiumName": l.name, "graphics": graphics_on(l.id)});+ if let Some(k) = l.kind { v["kind"] = json!(k); }+ v+ }).collect()+}++#[cfg(test)]+mod tests {+ use super::*;++ fn template() -> Vec<Layer> {+ // as the agent read MartyPM's "Default Footprint" (#41) on AD 26.11+ table(&json!([[1, "Top Layer", -1], [33, "Top Overlay", -1], [67108917, "Top Assembly", 1], [67108921, "Top Component Center", 7],+ [67108923, "Top Component Outline", 9], [67108925, "Top Courtyard", 11], [67108927, "Top Designator", 13]]))+ }++ #[test]+ fn typed_layers_keep_their_altium_names_and_kinds() {+ let l = template();+ assert_eq!(display_name(33, &l), "F.SilkS");+ assert_eq!(display_name(67108925, &l), "Top Courtyard");+ assert_eq!(l.iter().find(|x| x.id == 67108925).unwrap().kind, Some("CourtyardTop"));+ assert_eq!(l.iter().find(|x| x.id == 33).unwrap().kind, None, "a layer that is not mechanical has no kind");+ }++ #[test]+ fn the_courtyard_is_the_typed_courtyard_else_mechanical_15() {+ assert_eq!(courtyard_layers(&template()), vec![67108925]);+ let old = table(&json!([[1, "Top Layer", -1], [69, "Fab", 0], [71, "Courtyard", 0]]));+ assert_eq!(courtyard_layers(&old), vec![71]);+ assert_eq!(courtyard_layers(&[]), vec![71], "an old agent sends no layers: Mechanical 15 as before");+ }++ #[test]+ fn details_count_the_graphics_on_each_layer() {+ let d = details(&template(), |id| if id == 67108925 { 4 } else { 0 });+ let c = d.iter().find(|x| x["id"] == 67108925).unwrap();+ assert_eq!(c["name"], "Top Courtyard");+ assert_eq!(c["kind"], "CourtyardTop");+ assert_eq!(c["graphics"], 4);+ assert!(d.iter().find(|x| x["id"] == 33).unwrap().get("kind").is_none());+ }+}
bridge-rs/src/main.rs+2−1@@ -9,6 +9,7 @@ mod assembly; mod installs; mod keepouts; mod gloss;+mod fplayers; mod autoclass; mod board; mod bodies;@@ -84,7 +85,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.111";+pub const BRIDGE_VERSION: &str = "0.2.112"; 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/project.rs+23−10@@ -363,28 +363,41 @@ pub fn read_footprint(args: &Value) -> Value { json!({"number": p[0], "type": if hole > 0.0 { if p[9].as_bool() == Some(false) { "npth" } else { "pth" } } else { "smd" }, "shape": shape(p[7].as_i64().unwrap_or(0)), "at": [mm(&p[1]), mm(&p[2])], "sizeMm": [mm(&p[3]), mm(&p[4])], "drillMm": hole, "layers": [layer], "rotation": p[8].as_f64().unwrap_or(0.0) / 1000.0}) }).collect();- // the same counts by Altium's layer id, which names nothing on a board's layer map (33 Top Overlay, 71 Mechanical 15)+ // each layer by the name the user sees (#41): a typed layer of AD 24+ as "Top Courtyard", silkscreen as F.SilkS+ let lt = crate::fplayers::table(&d["layers"]);+ let others = d["other"].as_array().cloned().unwrap_or_default(); let mut by_id = serde_json::Map::new();- for o in d["other"].as_array().cloned().unwrap_or_default() { let k = o[1].as_i64().unwrap_or(0).to_string(); let n = by_id.get(&k).and_then(|v| v.as_i64()).unwrap_or(0); by_id.insert(k, json!(n + 1)); } let mut graphics = serde_json::Map::new();- for o in d["other"].as_array().cloned().unwrap_or_default() { let l = crate::routing::layer_name(o[1].as_i64().unwrap_or(0)); *graphics.entry(l).or_insert(json!(0)) = json!(graphics.get(&crate::routing::layer_name(o[1].as_i64().unwrap_or(0))).and_then(|v| v.as_i64()).unwrap_or(0) + 1); }+ for o in &others {+ let id = o[1].as_i64().unwrap_or(0);+ let k = id.to_string(); let n = by_id.get(&k).and_then(|v| v.as_i64()).unwrap_or(0); by_id.insert(k, json!(n + 1));+ let name = crate::fplayers::display_name(id, <); let n = graphics.get(&name).and_then(|v| v.as_i64()).unwrap_or(0); graphics.insert(name, json!(n + 1));+ } let mut layers: Vec<String> = pads.iter().filter_map(|p| p["layers"][0].as_str().map(str::to_string)).chain(graphics.keys().cloned()).collect(); layers.sort(); layers.dedup();- // the courtyard: the extent of the Courtyard layer's graphics (Mechanical 15, layer 71, as this bridge's footprints- // and IPC wizards put it), else of everything but the pads; the library footprint itself has no extent in Altium- let others = d["other"].as_array().cloned().unwrap_or_default();+ // the courtyard: the extent of the courtyard layer's graphics (a Courtyard Top layer, else Mechanical 15 as this+ // bridge's footprints and IPC wizards put it), else of everything but the pads; the library footprint itself has no+ // extent in Altium let ext = |rows: Vec<&Value>| -> Option<[f64; 4]> { let mut b = [f64::MAX, f64::MAX, f64::MIN, f64::MIN]; for o in rows { if o.as_array().map(|a| a.len() >= 6).unwrap_or(false) { b[0] = b[0].min(mm(&o[2])); b[1] = b[1].min(mm(&o[3])); b[2] = b[2].max(mm(&o[4])); b[3] = b[3].max(mm(&o[5])); } } if b[0] <= b[2] { Some(b) } else { None } };- let court = ext(others.iter().filter(|o| o[1].as_i64() == Some(71)).collect()).or_else(|| ext(others.iter().collect()));+ let cy = crate::fplayers::courtyard_layers(<);+ let court = ext(others.iter().filter(|o| o[1].as_i64().is_some_and(|i| cy.contains(&i))).collect()).or_else(|| ext(others.iter().collect())); let b = court.map(|c| json!(c)).unwrap_or(d["box"].clone());- let models: Vec<Value> = d["bodies"].as_array().cloned().unwrap_or_default().iter().map(|x| json!({"path": x["model"], "heightMm": mm(&x["overallHeight"]), "standoffMm": mm(&x["standoff"])})).collect();+ let texts: Vec<Value> = others.iter().filter(|o| o[6].is_string()).map(|o| json!({"text": o[6], "layer": crate::fplayers::display_name(o[1].as_i64().unwrap_or(0), <),+ "boxMm": [mm(&o[2]), mm(&o[3]), mm(&o[4]), mm(&o[5])]})).collect();+ let layer_details = crate::fplayers::details(<, |id| others.iter().filter(|o| o[1].as_i64() == Some(id)).count());+ let models: Vec<Value> = d["bodies"].as_array().cloned().unwrap_or_default().iter().map(|x| {+ let mut m = json!({"path": x["model"], "heightMm": mm(&x["overallHeight"]), "standoffMm": mm(&x["standoff"])});+ if let Some(l) = x["layer"].as_i64() { m["layer"] = json!(crate::fplayers::display_name(l, <)); }+ m+ }).collect(); json!({"success": true, "name": d["name"], "library": lib, "description": d["description"], "pads": pads, "layers": layers, "courtyardMm": if court.is_some() { b.clone() } else { json!([mm(&b[0]), mm(&b[1]), mm(&b[2]), mm(&b[3])]) },- "graphics": graphics, "graphicsLayerIds": by_id, "attributes": {"mount": if pads.iter().any(|p| p["type"] == "pth") { "through_hole" } else { "smd" }},+ "graphics": graphics, "graphicsLayerIds": by_id, "layerDetails": layer_details, "texts": texts, "attributes": {"mount": if pads.iter().any(|p| p["type"] == "pth") { "through_hole" } else { "smd" }}, "properties": {"description": d["description"], "heightMm": mm(&d["height"])}, "models": models,- "_hint": "Positions from the footprint's origin, mm. courtyardMm is the footprint's bounding box (Altium courtyards are a mechanical layer's graphics). altium_footprint_primitives reads a placed part."})+ "_hint": "Positions from the footprint's origin, mm. Graphics are counted per layer by the name Altium shows (typed layers of AD 24+ as Top Courtyard, Top Assembly); layerDetails gives each layer's id and kind, texts the strings (the .Designator). courtyardMm is the extent of the courtyard layer's graphics, else of all graphics. altium_footprint_primitives reads a placed part."}) } #[cfg(test)]
bridge-rs/src/verbs.rs+16−4@@ -650,7 +650,7 @@ fn describe() -> Value { &["routing_state", "run_command", "animate_view"], &["Needs the board current.", "Coordinates are Altium's (y up), as routing_state reports them."], json!({"net": "SW", "margin": 0.5})), verb_doc("footprint_primitives", "Geometry dump of one PLACED component: its tracks, arcs, pads (with solder and paste mask expansion in um) and texts in mils with layer ids; other primitive kinds are counted.", json!({"designator": "string (required) - a component on the current board, e.g. U1"}),- json!({"data": "{designator, pattern, count, otherPrimitives, primitives: [{kind: track|arc|pad|text, layerId, ...}]}", "roundtripMs": "int"}), 120,+ json!({"data": "{designator, pattern, count, otherPrimitives, primitives: [{kind: track|arc|pad|text, layerId, layer, ...}], layerDetails: [{id, name, altiumName, kind?, graphics}]}", "roundtripMs": "int"}), 120, "Use it to verify an imported footprint on a altium_test_board: pad layerId 74 = multi-layer (plated through), which is what altium_plate_vias produces.", &["component_pins", "plate_vias", "test_board", "pcb_report"], &["Needs a .PcbDoc current: it reads a placed component, not a PcbLib member (altium_pcb_report reads libraries).", "3D bodies, fills and regions only show up in otherPrimitives."], json!({"designator": "U1"})), verb_doc("schematic_data", "Components on a schematic sheet (filePath, else the CURRENT sheet) with their pins (number, name, electrical type), position and orientation. designator filters to one part.",@@ -968,8 +968,8 @@ fn describe() -> Value { "Reads the open board when the tool serves it, else the file.", &[], &["linked:false means the board part has no link to a symbol: placed by hand, or update_pcb never ran.", "Sheets are read from their saved files; a part matched by designator alone is linked:false."], json!({"filePath": "C:/proj/Board.PcbDoc", "ref": "U3"})), verb_doc("read_footprint", "Every detail of one library footprint: pads (number, type, shape, position, size, drill, layers), the layers it uses, its courtyard box, graphics per layer, attributes, properties and 3D models. The library mirror of read_symbol; footprint_primitives reads a part placed on the board.", json!({"libraryPath": "path to the footprint library", "name": "the footprint's name (with libraryPath)", "libId": "\"Lib:Name\": resolved through the project's and then the global library table", "project": "path to the project, for libId"}),- json!({"name": "string", "pads": "[{number, type, shape, at, sizeMm, drillMm, layers, rotation}]", "layers": "[string]", "courtyardMm": "[x1, y1, x2, y2]", "graphics": "{layer: count}", "attributes": "{mount, excludeFromBom, excludeFromPos, dnp}", "properties": "{name: value}", "models": "[{path, offset, scale, rotate}]"}), 300,- "Read before edit_footprint, and to check pin 1 and the pad numbers against the symbol.", &[], &["Altium has no library table: give libraryPath and name (libId is not used). courtyardMm is the footprint's bounding box."], json!({"libId": "Package_SO:SOIC-8_3.9x4.9mm_P1.27mm"})),+ json!({"name": "string", "pads": "[{number, type, shape, at, sizeMm, drillMm, layers, rotation}]", "layers": "[string]", "courtyardMm": "[x1, y1, x2, y2]", "graphics": "{layer: count}: F.SilkS for silkscreen, else the name Altium shows (Top Courtyard, Mechanical 15)", "layerDetails": "[{id, name, altiumName, kind?, graphics}]: kind is a typed component layer's type (CourtyardTop, AssemblyTop, DesignatorTop, 3DBodyTop, ...)", "texts": "[{text, layer, boxMm}]: the .Designator string and other texts", "attributes": "{mount, excludeFromBom, excludeFromPos, dnp}", "properties": "{name: value}", "models": "[{path, heightMm, standoffMm, layer}]"}), 300,+ "Read before edit_footprint, and to check pin 1 and the pad numbers against the symbol.", &[], &["Altium has no library table: give libraryPath and name (libId is not used).", "courtyardMm is the extent of the courtyard layer's graphics: a Top Courtyard layer (AD 24+ typed layers), else Mechanical 15, else all graphics.", "Before 0.2.112 graphics on the typed component layers of AD 24+ (above Mechanical 16) were not read at all."], json!({"libId": "Package_SO:SOIC-8_3.9x4.9mm_P1.27mm"})), verb_doc("render_board_3d", "Render a 3D picture of the board from one side to an image file, through the tool's own renderer, without opening a window.", json!({"filePath": "path to the board file (default: the board open in the tool)", "side": "top|bottom|left|right|front|back, default top", "width": "int px, default 1600", "height": "int px, default 900", "quality": "basic|high, default basic (high raytraces and is much slower)", "background": "default|transparent|opaque", "zoom": "number, default 1.0", "perspective": "bool, default false", "format": "png|jpg, default png", "outputDir": "folder for the output (default beside the board)"}), json!({"image": "path", "width": "int", "height": "int", "side": "string"}), 600,@@ -2063,7 +2063,19 @@ pub fn dispatch(command: &str, args: &Value, _forwarded: &[(String, String)]) -> } "footprint_primitives" => match s(args, "designator") { None => json!({"success": false, "error": "designator is required (a placed component, e.g. U1)"}),- Some(d) => board_read("footprint_primitives", vec![("designator", d)], 120),+ Some(d) => {+ // each primitive's layer by the name Altium shows, typed layers included (#41)+ let mut r = board_read("footprint_primitives", vec![("designator", d)], 120);+ if let Some(data) = r.get_mut("data") {+ let lt = crate::fplayers::table(&data["layers"]);+ if let Some(items) = data.get_mut("primitives").and_then(|v| v.as_array_mut()) {+ for it in items.iter_mut() { if let Some(id) = it["layerId"].as_i64() { it["layer"] = json!(crate::fplayers::display_name(id, <)); } }+ }+ let details = crate::fplayers::details(<, |id| data["primitives"].as_array().map(|a| a.iter().filter(|x| x["layerId"].as_i64() == Some(id) && x["kind"] != "pad").count()).unwrap_or(0));+ data["layerDetails"] = json!(details);+ }+ r+ } }, "schematic_data" => { // a named sheet becomes the current document first; without one the verb reads the current sheet
package.json+1−1@@ -1,6 +1,6 @@ { "slug": "altium-bridge",- "version": "0.2.111",+ "version": "0.2.112", "type": "app", "description": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.", "tags": [
page.json+2−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.111",+ "version": "0.2.112", "hero": { "type": "image", "path": "screenshots/hero.png"@@ -159,4 +159,4 @@ "tools/symbol_modes.py", "uninstall.sh" ]-}+}
scripts/release.py+18@@ -210,6 +210,24 @@ def lint_agent_script(): if n in seen: hits.append(f"routine {m.group(1)} is declared twice (lines {seen[n]} and {code[:m.start()].count(chr(10)) + 1})") seen.setdefault(n, code[:m.start()].count(chr(10)) + 1)+ # A routine called above its declaration halts the engine when the caller runs ("Undeclared identifier:+ # NoteLayer", 2026-11-30, #41): DelphiScript has no forward declarations here. Comments are blanked line for line+ # so positions stay true.+ decl_code = re.sub(r"\{[^}]*\}", lambda m: re.sub(r"[^\n]", " ", m.group(0)), src)+ decl_code = re.sub(r"'[^'\n]*'", "''", re.sub(r"//[^\n]*", "", decl_code))+ decls = {}+ for m in re.finditer(r"^(?:Function|Procedure)\s+([A-Za-z_][A-Za-z0-9_]*)", decl_code, flags=re.M):+ decls.setdefault(m.group(1).lower(), (m.group(1), m.start()))+ for low, (name, pos) in decls.items():+ u = re.search(r"(?<![A-Za-z0-9_.])" + re.escape(low) + r"(?![A-Za-z0-9_])", decl_code[:pos], flags=re.I)+ if u:+ hits.append(f"{name} is used at line {decl_code[:u.start()].count(chr(10)) + 1} before its declaration at line {decl_code[:pos].count(chr(10)) + 1}")+ # A reserved word as a parameter or variable name halts the engine at compile: a parameter named Out did+ # (2026-11-30, #41). Out is a parameter modifier in DelphiScript.+ for m in re.finditer(r"(?:\(|;)\s*(?:Var\s+|Const\s+)?(Out|Type|Label)\s*:\s*[A-Za-z]", code, flags=re.I):+ hits.append(f"reserved word {m.group(1)} named as a parameter -> ...{code[max(0, m.start() - 40):m.end() + 20].strip()}...")+ for m in re.finditer(r"^\s+(Out|Type|Label)\s*(?:,[^:\n]*)?:\s*[A-Za-z]", code, flags=re.M | re.I):+ hits.append(f"reserved word {m.group(1)} named as a variable -> ...{code[max(0, m.start() - 10):m.end() + 20].strip()}...") if hits: raise SystemExit("agent template uses engine-halting identifiers (see ENGINE_HALTING):\n " + "\n ".join(hits))
skills/altium-libraries/SKILL.md+5−2@@ -193,8 +193,11 @@ altium_footprint_from_land_pattern '{"libraryPath":"C:\\lib\\Parts.PcbLib","name ## A part on its own: read, show, export, a demo project (0.2.77) - `altium_read_footprint {libraryPath, name}`: pads (number, position, size, shape, layers, hole), the layers used and- the courtyard, in mm from the footprint's origin (not the library's sheet). The courtyard is the extent of the- Mechanical 15 graphics, else of everything but the pads.+ the courtyard, in mm from the footprint's origin (not the library's sheet). The courtyard is the extent of a Top+ Courtyard layer's graphics, else Mechanical 15's, else of everything but the pads. From 0.2.112 it reads the typed+ component layers of AD 24+ (Top Assembly, Top Courtyard, Top Designator, Top 3D Body, ...): `layerDetails` gives each+ layer's Altium name and kind, `texts` the `.Designator` string and other texts. Placing or copying a footprint still+ drops graphics on those layers (#41). - `altium_library_views {libraryPath, parts, views?}`: images of the symbol, the footprint and its 3D body (`device` is KiCad's; Altium answers it as not in Altium); a view the part lacks is listed with why. - `altium_export_library_part {part, libraryPath, outputDir?, what?}`: `<part>.SchLib` and `<part>.PcbLib` holding only
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-0.2.111+0.2.112
src/agent/AdomAgent.pas.tmpl+66−10@@ -5881,6 +5881,52 @@ Begin Result := '{' + JRaw('ok','true') + ',' + JStr('pair', Name) + ',' + JStr('pos', PN.Name) + ',' + JStr('neg', NN.Name) + ',' + JRaw('replaced', JBool(Old <> Nil)) + '}'; End; +{ The mechanical layer number of a layer id, 0 for any other layer: Mechanical 1-16 keep their old ids (57-72), the+ rest (AD 19+, up to 1024) are 67108864 + N. The typed component layers of AD 24+ (Top Assembly, Top Courtyard,+ Top 3D Body, ...) are mechanical layers with a kind, usually above 16 (#41). }+Function MechLayerNo(L : Integer) : Integer;+Begin+ Result := 0;+ If (L >= 57) And (L <= 72) Then Result := L - 56+ Else If (L > 67108864) And (L <= 67109888) Then Result := L - 67108864;+End;++{ One layer as [id, "name", kind]: the name the user sees in Altium (a mechanical layer's own name, as "Top Courtyard")+ and a mechanical layer's kind (0 none, 11 Courtyard Top, ...; -1 for a layer that is not mechanical).+ LayerStack.LayerObject reads only the low byte of the id (67108921 came back as Mechanical 1, 2026-11-30), so a+ mechanical layer is looked up by its number. }+Function LayerInfoJson(Board : IPCB_Board; L : Integer) : String;+Var+ ML : IPCB_MechanicalLayer;+ N, K : Integer;+ Nm : String;+Begin+ Nm := Layer2String(L); K := -1; N := MechLayerNo(L);+ If N > 0 Then+ Begin+ K := 0;+ Try+ ML := Board.MasterLayerStack.GetMechanicalLayer(N);+ If ML <> Nil Then+ Begin+ If ML.Name <> '' Then Nm := ML.Name;+ Try K := ML.Kind; Except K := 0; End;+ End;+ Except End;+ End;+ Result := '[' + IntToStr(L) + ',"' + JsonEsc(Nm) + '",' + IntToStr(K) + ']';+End;++{ Adds L to the comma-wrapped list Seen (',1,33,') and its [id, name, kind] to Acc when it is new. (Out is a reserved+ word in DelphiScript: a parameter named Out halts the engine on compile.) }+Procedure NoteLayer(Board : IPCB_Board; L : Integer; Var Seen : String; Var Acc : String);+Begin+ If Pos(',' + IntToStr(L) + ',', Seen) > 0 Then Exit;+ Seen := Seen + IntToStr(L) + ',';+ If Acc <> '' Then Acc := Acc + ',';+ Acc := Acc + LayerInfoJson(Board, L);+End;+ { footprint_primitives: designator=<board component> -> geometry dump (tracks, arcs, pads, texts, others counted) } Function CmdFootprintPrimitives(Lines : TStringList) : String; Var@@ -5892,7 +5938,7 @@ Var Arc : IPCB_Arc; Pad : IPCB_Pad; Txt : IPCB_Text;- Des, S, Item : String;+ Des, S, Item, Seen, LJ : String; K, Other : Integer; Begin Board := PCBServer.GetCurrentPCBBoard;@@ -5901,9 +5947,10 @@ Begin If Des = '' Then Begin Result := '{' + JRaw('ok','false') + ',' + JStr('error','designator is required') + '}'; Exit; End; Comp := FindCompByDes(Board, Des); If Comp = Nil Then Begin Result := '{' + JRaw('ok','false') + ',' + JStr('error','designator not found: ' + Des) + '}'; Exit; End;- S := ''; K := 0; Other := 0;+ S := ''; K := 0; Other := 0; Seen := ','; LJ := ''; GIt := Comp.GroupIterator_Create;- GIt.AddFilter_LayerSet(AllLayers);+ { the IPCB layer set, so the typed component layers above Mechanical 16 are read too (#41) }+ GIt.AddFilter_IPCB_LayerSet(LayerSetUtils.AllLayers); Prim := GIt.FirstPCBObject; While (Prim <> Nil) And (K < 2000) Do Begin@@ -5942,6 +5989,7 @@ Begin JRaw('x', IntToStr(Round(CoordToMils(Txt.XLocation)))) + ',' + JRaw('y', IntToStr(Round(CoordToMils(Txt.YLocation)))) + '}'; End Else Other := Other + 1;+ NoteLayer(Board, Prim.Layer, Seen, LJ); If Item <> '' Then Begin If S <> '' Then S := S + ',';@@ -5952,7 +6000,7 @@ Begin End; Comp.GroupIterator_Destroy(GIt); Result := '{' + JRaw('ok','true') + ',' + JStr('designator', Comp.Name.Text) + ',' + JStr('pattern', Comp.Pattern) + ',' +- JRaw('count', IntToStr(K)) + ',' + JRaw('otherPrimitives', IntToStr(Other)) + ',' + JRaw('primitives', '[' + S + ']') + '}';+ JRaw('count', IntToStr(K)) + ',' + JRaw('otherPrimitives', IntToStr(Other)) + ',' + JRaw('primitives', '[' + S + ']') + ',' + JRaw('layers', '[' + LJ + ']') + '}'; End; { I/O bench: where does the ~300 ms per file write go? Times TStringList.SaveToFile against@@ -10684,7 +10732,7 @@ Var GIt : IPCB_GroupIterator; Prim : IPCB_Primitive; Pad : IPCB_Pad;- S, B, L, Nm, Mf : String;+ S, B, L, Nm, Mf, Seen, LJ, Tx : String; I, OX, OY : Integer; R : TCoordRect; Begin@@ -10698,19 +10746,22 @@ Begin For I := 0 To PLib.ComponentCount - 1 Do If UpperCase(PLib.GetComponent(I).Name) = UpperCase(Nm) Then Begin Fp := PLib.GetComponent(I); Break; End; If Fp = Nil Then Begin Result := '{' + JRaw('ok','false') + ',' + JStr('errorCode','footprint_not_found') + ',' + JStr('error','no footprint ' + Nm + ' in this library') + '}'; Exit; End;- S := ''; B := ''; L := '';+ S := ''; B := ''; L := ''; Seen := ','; LJ := ''; { positions from the footprint's origin. Only the footprint on display sits on the library's origin; another keeps raw coordinates near 0 (one library read +1270 mm, another -1272.7 mm, 2026-10-28), so it is shown first } If PLib.CurrentComponent <> Fp Then Begin PLib.CurrentComponent := Fp; PLib.Board.ViewManager_FullUpdate; End; OX := PLib.Board.XOrigin; OY := PLib.Board.YOrigin; GIt := Fp.GroupIterator_Create;- GIt.AddFilter_LayerSet(AllLayers);+ { the IPCB layer set: AllLayers leaves out mechanical layers above 16, where AD 24+ keeps its typed component+ layers (Top Assembly, Top Courtyard, Top Designator, ...), so a footprint drawn on them read as empty (#41) }+ GIt.AddFilter_IPCB_LayerSet(LayerSetUtils.AllLayers); Prim := GIt.FirstPCBObject; While Prim <> Nil Do Begin If Prim.ObjectId = ePadObject Then Begin Pad := Prim;+ NoteLayer(PLib.Board, Pad.Layer, Seen, LJ); If S <> '' Then S := S + ','; S := S + '[' + '"' + JsonEsc(Pad.Name) + '",' + IntToStr(Pad.x - OX) + ',' + IntToStr(Pad.y - OY) + ',' + IntToStr(Pad.TopXSize) + ',' + IntToStr(Pad.TopYSize) + ',' + IntToStr(Pad.HoleSize) + ',' + IntToStr(Pad.Layer) + ',' + IntToStr(Pad.TopShape) + ',' + IntToStr(Round(Pad.Rotation * 1000)) + ',' + JBool(Pad.Plated) + ']';@@ -10719,14 +10770,19 @@ Begin Begin Mf := ''; Try If Prim.Model <> Nil Then Mf := Prim.Model.FileName; Except End;+ NoteLayer(PLib.Board, Prim.Layer, Seen, LJ); If B <> '' Then B := B + ',';- B := B + '{' + JStr('model', Mf) + ',' + JRaw('overallHeight', IntToStr(Prim.OverallHeight)) + ',' + JRaw('standoff', IntToStr(Prim.StandoffHeight)) + '}';+ B := B + '{' + JStr('model', Mf) + ',' + JRaw('overallHeight', IntToStr(Prim.OverallHeight)) + ',' + JRaw('standoff', IntToStr(Prim.StandoffHeight)) + ',' + JRaw('layer', IntToStr(Prim.Layer)) + '}'; End Else Begin R := Prim.BoundingRectangle;+ NoteLayer(PLib.Board, Prim.Layer, Seen, LJ);+ { a text carries its string (the template's .Designator) as a seventh field }+ Tx := '';+ If Prim.ObjectId = eTextObject Then Tx := ',"' + JsonEsc(Prim.Text) + '"'; If L <> '' Then L := L + ',';- L := L + '[' + IntToStr(Prim.ObjectId) + ',' + IntToStr(Prim.Layer) + ',' + IntToStr(R.Left - OX) + ',' + IntToStr(R.Bottom - OY) + ',' + IntToStr(R.Right - OX) + ',' + IntToStr(R.Top - OY) + ']';+ L := L + '[' + IntToStr(Prim.ObjectId) + ',' + IntToStr(Prim.Layer) + ',' + IntToStr(R.Left - OX) + ',' + IntToStr(R.Bottom - OY) + ',' + IntToStr(R.Right - OX) + ',' + IntToStr(R.Top - OY) + Tx + ']'; End; Prim := GIt.NextPCBObject; End;@@ -10734,7 +10790,7 @@ Begin R := Fp.BoundingRectangle; Result := '{' + JRaw('ok','true') + ',' + JStr('name', Fp.Name) + ',' + JStr('description', Fp.Description) + ',' + JRaw('height', IntToStr(Fp.Height)) + ',' + JRaw('k', IntToStr(MilsToCoord(1000))) + ',' + JRaw('origin', '[' + IntToStr(OX) + ',' + IntToStr(OY) + ']') + ',' + JStr('libraryFile', PLib.Board.FileName) + ',' + JRaw('box', '[' + IntToStr(R.Left - OX) + ',' + IntToStr(R.Bottom - OY) + ',' + IntToStr(R.Right - OX) + ',' + IntToStr(R.Top - OY) + ']') + ',' +- JRaw('pads', '[' + S + ']') + ',' + JRaw('bodies', '[' + B + ']') + ',' + JRaw('other', '[' + L + ']') + '}';+ JRaw('pads', '[' + S + ']') + ',' + JRaw('bodies', '[' + B + ']') + ',' + JRaw('other', '[' + L + ']') + ',' + JRaw('layers', '[' + LJ + ']') + '}'; End;
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "altium", "displayName": "Altium Designer",- "version": "0.2.111",+ "version": "0.2.112", "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",