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.108: keepouts in routing_state; engine 0.26.0 (plan_route keepouts, fab_check edge clearance)
16 files changed
+332−36
CHANGELOG.md+7bridge-rs/Cargo.lock+1−1bridge-rs/src/keepouts.rs+106bridge-rs/src/main.rs+2−1bridge-rs/src/routing.rs+2bridge-rs/vendor/README.md+1−1bridge-rs/vendor/adom-eda-checks/Cargo.toml+1−1bridge-rs/vendor/adom-eda-checks/README.md+2−2bridge-rs/vendor/adom-eda-checks/src/fab.rs+81−18bridge-rs/vendor/adom-eda-checks/src/route.rs+71−3bridge-rs/vendor/adom-eda-checks/tests/fixtures.rs+4−1package.json+1−1page.json+1−1src/BRIDGE_VERSION+1−1src/agent/AdomAgent.pas.tmpl+50−4src/bridge.json+1−1CHANGELOG.md+7@@ -1,5 +1,12 @@ # Changelog +## 0.2.108++- **`altium_routing_state` lists the board's keepouts** (eda-bridge-standard#33). Keepout tracks, arcs, fills and regions, and anything on the Keep-Out layer, footprints' own included, come back in `keepouts[]`: `{name, kind, layers, points}` in mm, the area each covers (a track's band, an arc's curved band, a fill's rotated rectangle, a region's outline). The Keep-Out layer is `*.Cu`, every copper layer. `tracks[]` is unchanged.+- **`altium_plan_route` keeps out of them.** It runs the standard's engine 0.26.0 (standard 0.34.0, vendored), which routes round keepouts and, when they leave no path, names them in `keepoutsInTheWay`. A keepout is treated as keeping out both tracks and vias, Altium's default. A keepout that allows one of them is not told apart yet.+- **`altium_fab_check` measures copper to the board edge correctly** (engine 0.26.0, from kicad-bridge#155/#156). Each pad's real outline and each track's whole length are measured. Before, a pad counted as a circle of half its long side, and a pad turned 45 degrees could pass a real violation. Copper wholly outside the outline is listed in `measured.outsideOutline`.+- Tested on Altium Designer 26.11.1: a keepout track, fill and region read back with their layers and outlines; `altium_plan_route` went round a Keep-Out-layer wall through the gap beside it, and named the wall when the gap was closed. The battery cases for `altium_routing_state`, `altium_plan_route`, `altium_fab_check` and `altium_routing_drc` passed, and a 10,000-track board read no slower.+ ## 0.2.107 - **`altium_set_design_rules` can leave a board's own rules alone** (adom-aiflow#228). It wrote each value into every rule of its kind, so raising a fab floor also overwrote a board's tighter hand-set rules and its net-class width rules. Two options, both off by default:
bridge-rs/Cargo.lock+1−1@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "adom-eda-checks"-version = "0.25.0"+version = "0.26.0" dependencies = [ "roxmltree", "serde_json",
bridge-rs/src/keepouts.rsadded+106@@ -0,0 +1,106 @@+//! Keepouts in the board model, as the standard reads them (engine 0.26.0's plan_route keeps out of them):+//! `[{layers, points, kind, name}]` in mm. Altium's keepouts are tracks, arcs, fills and regions marked keepout, and+//! anything on the Keep-Out layer (every copper layer). Each comes as the area its copper would have covered: a track+//! its band (square ends: a little more room than Altium keeps, never less), an arc its curved band, a fill its rotated+//! rectangle, a region its outline. No `rules` are sent, which the standard reads as tracks and vias both kept out:+//! Altium's default for a keepout. Which objects a restricted keepout allows is not read yet (the script API names it+//! differently on this build), so such a keepout is treated as keeping out both.+use serde_json::{json, Value};++/// Altium's Keep-Out layer id: a keepout there applies to every copper layer.+const KEEP_OUT_LAYER: i64 = 56;++fn n(v: &Value) -> f64 {+ v.as_f64().unwrap_or(0.0)+}++fn r4(v: f64) -> f64 {+ (v * 10000.0).round() / 10000.0+}++/// The band a straight piece of copper of half-width `h` covers, as a rectangle with square ends.+fn band(a: (f64, f64), b: (f64, f64), h: f64) -> Vec<(f64, f64)> {+ let (dx, dy) = (b.0 - a.0, b.1 - a.1);+ let len = (dx * dx + dy * dy).sqrt();+ let (ux, uy) = if len < 1e-9 { (1.0, 0.0) } else { (dx / len, dy / len) };+ let (nx, ny) = (-uy * h, ux * h);+ let (ex, ey) = (ux * h, uy * h);+ vec![(a.0 - ex + nx, a.1 - ey + ny), (b.0 + ex + nx, b.1 + ey + ny), (b.0 + ex - nx, b.1 + ey - ny), (a.0 - ex - nx, a.1 - ey - ny)]+}++/// The curved band an arc of half-width `h` covers: its outer edge forward, its inner edge back.+fn arc_band(c: (f64, f64), r: f64, a1: f64, a2: f64, h: f64) -> Vec<(f64, f64)> {+ let mut sweep = a2 - a1;+ if sweep <= 0.0 { sweep += 360.0; }+ let steps = ((sweep / 10.0).ceil() as usize).max(4);+ let at = |rad: f64, i: usize| {+ let t = (a1 + sweep * i as f64 / steps as f64).to_radians();+ (c.0 + rad * t.cos(), c.1 + rad * t.sin())+ };+ let mut pts: Vec<(f64, f64)> = (0..=steps).map(|i| at(r + h, i)).collect();+ pts.extend((0..=steps).rev().map(|i| at((r - h).max(0.0), i)));+ pts+}++/// A fill's rectangle turned by its rotation (degrees) about its centre.+fn fill_rect(x1: f64, y1: f64, x2: f64, y2: f64, rot: f64) -> Vec<(f64, f64)> {+ let (cx, cy) = ((x1 + x2) / 2.0, (y1 + y2) / 2.0);+ let (s, c) = rot.to_radians().sin_cos();+ [(x1, y1), (x2, y1), (x2, y2), (x1, y2)].iter()+ .map(|(x, y)| { let (dx, dy) = (x - cx, y - cy); (cx + dx * c - dy * s, cy + dx * s + dy * c) }).collect()+}++/// The agent's raw keepout rows (`["t", layer, x1, y1, x2, y2, width]`, `["a", layer, cx, cy, r, a1*1000, a2*1000,+/// width]`, `["f", layer, x1, y1, x2, y2, rot*1000]`, `["r", layer, [[x, y], ...]]`, raw units) as the board model's+/// keepouts. `to_mm` converts raw units; `layer` names a copper layer id. A keepout on a layer that is not copper is+/// left out. Pure.+pub fn shape(raw: &[Value], to_mm: impl Fn(f64) -> f64, layer: impl Fn(i64) -> String) -> Vec<Value> {+ let mut out = Vec::new();+ for (i, k) in raw.iter().enumerate() {+ let id = k[1].as_i64().unwrap_or(-1);+ let lname = if id == KEEP_OUT_LAYER { "*.Cu".to_string() } else { layer(id) };+ if !(lname == "*.Cu" || lname.ends_with(".Cu")) { continue; }+ let m = |j: usize| to_mm(n(&k[j]));+ let (kind, pts) = match k[0].as_str().unwrap_or("") {+ "t" => ("track", band((m(2), m(3)), (m(4), m(5)), m(6) / 2.0)),+ "a" => ("arc", arc_band((m(2), m(3)), m(4), n(&k[5]) / 1000.0, n(&k[6]) / 1000.0, m(7) / 2.0)),+ "f" => ("fill", fill_rect(m(2), m(3), m(4), m(5), n(&k[6]) / 1000.0)),+ "r" => ("region", k[2].as_array().cloned().unwrap_or_default().iter().map(|p| (to_mm(n(&p[0])), to_mm(n(&p[1])))).collect()),+ _ => continue,+ };+ if pts.len() < 3 { continue; }+ out.push(json!({"name": format!("keepout {kind} {}", i + 1), "kind": kind, "layers": [lname],+ "points": pts.iter().map(|(x, y)| json!([r4(*x), r4(*y)])).collect::<Vec<_>>()}));+ }+ out+}++#[cfg(test)]+mod tests {+ use super::*;++ fn layer(id: i64) -> String {+ match id { 1 => "F.Cu".into(), 32 => "B.Cu".into(), _ => format!("L{id}") }+ }++ #[test]+ fn each_keepout_is_the_area_it_covers_on_its_layers() {+ let raw = vec![+ json!(["t", 56, 0, 0, 10, 0, 2]),+ json!(["f", 1, 0, 0, 4, 2, 90000]),+ json!(["r", 32, [[0, 0], [3, 0], [0, 3]]]),+ json!(["a", 1, 0, 0, 5, 0, 90000, 2]),+ json!(["t", 33, 0, 0, 1, 1, 1]),+ ];+ let k = shape(&raw, |v| v, layer);+ assert_eq!(k.len(), 4, "the keepout on a layer that is not copper is left out: {k:?}");+ assert_eq!(k[0]["layers"], json!(["*.Cu"]), "the Keep-Out layer is every copper layer");+ assert_eq!(k[0]["points"], json!([[-1.0, 1.0], [11.0, 1.0], [11.0, -1.0], [-1.0, -1.0]]), "a track's band with square ends");+ assert_eq!(k[1]["points"], json!([[3.0, -1.0], [3.0, 3.0], [1.0, 3.0], [1.0, -1.0]]), "a fill turned 90 degrees about its centre");+ assert_eq!(k[2]["kind"], json!("region"));+ assert_eq!(k[2]["layers"], json!(["B.Cu"]));+ let arc: Vec<(f64, f64)> = k[3]["points"].as_array().unwrap().iter().map(|p| (n(&p[0]), n(&p[1]))).collect();+ assert!(arc.iter().all(|(x, y)| { let r = (x * x + y * y).sqrt(); r > 3.99 && r < 6.01 }), "an arc's band lies between r-h and r+h");+ assert!(k.iter().all(|x| x.get("rules").is_none()), "no rules: tracks and vias both kept out");+ }+}
bridge-rs/src/main.rs+2−1@@ -7,6 +7,7 @@ mod agent; mod dsnwrk; mod assembly; mod installs;+mod keepouts; mod autoclass; mod board; mod bodies;@@ -82,7 +83,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.107";+pub const BRIDGE_VERSION: &str = "0.2.108"; 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/routing.rs+2@@ -318,6 +318,8 @@ pub fn shape(d: &Value) -> Value { "unconnected": d.get("unrouted").cloned().unwrap_or(json!(0)), "nets": nets, "tracks": tracks, "arcs": arcs, "vias": vias, "pads": pads, "components": comps, "polygons": polys, "outline": outline, "outlineEdges": edges,+ // keepout tracks, arcs, fills and regions as areas (engine 0.26.0's plan_route keeps out of them)+ "keepouts": crate::keepouts::shape(arr(d, "keepouts"), |v| v / PER_MM, layer_name), }); // the count AI Flow judges is the copper's own; Altium's ratsnest count rides along let (n, split, isolated) = unrouted(&out);
bridge-rs/vendor/README.md+1−1@@ -2,7 +2,7 @@ | Folder | From | Version | |---|---|---|-| `adom-eda-checks/` | adom/eda-bridge-standard `engine/` (the shared checks engine) | standard 0.33.0, engine 0.25.0 |+| `adom-eda-checks/` | adom/eda-bridge-standard `engine/` (the shared checks engine) | standard 0.34.0, engine 0.26.0 | | `pcb-design-rules/records/` | adom/pcb-design-rules `rules/records/` (each fab's published limits, with sources and dates) | head of 2026-10-27 | The wiki has no git protocol, so these are copied at a version: refresh both from their pages, then run the tests.
bridge-rs/vendor/adom-eda-checks/Cargo.toml+1−1@@ -1,6 +1,6 @@ [package] name = "adom-eda-checks"-version = "0.25.0"+version = "0.26.0" edition = "2021" description = "The EDA Bridge Standard's checks and board-file writers, computed from the board model JSON: no bridge calls, no tool." license = "MIT"
bridge-rs/vendor/adom-eda-checks/README.md+2−2@@ -21,7 +21,7 @@ boards the engine gives the same answers the Altium bridge 0.2.76 gives. | `return_path` | board, stack, pours | signal tracks running over a gap in the neighbouring layer's reference copper, with a pour plan that closes each gap (`apply_pours`) | | `estimate_cost` | board, stack?, rules?, prices? | the numbers a fab quote needs (size, copper layers, thickness from the stack, smallest track, gap from the clearance rule, smallest drill, holes, SMD and through-hole parts and joints, unique parts, assembled sides) and, with a `prices` record, a rough table at `quantities` (default 5, 10, 30, 100), with assembly when asked, every assumption stated and the record named in `source`. The engine carries no rates: without `prices` the reply is the numbers only. From the KiCad bridge's fab.rs | | `find_space` | board, bodies? | free spots for a part (`part`, or `sizeMm`) near another (`near`) or a point (`at`): clear of other part boxes on that side by `clearanceMm`, of that side's routed tracks and the vias, `edgeMm` inside the outline (arcs sampled), nearest first, as where the part's origin goes; `check: true` lists parts that overlap (and, with bodies, those `stacked` under a raised one) or have pads off the outline, as placement_check judges them. Pours do not block (they re-pour). From the Altium bridge's design.rs |-| `fab_check` | board, stack?, rules?, silk?, fab? | the board's smallest features, compared with a fab's limits from adom/pcb-design-rules; each finding names the fab's page and the date it was read |+| `fab_check` | board, stack?, rules?, silk?, fab? | the board's smallest features, compared with a fab's limits from adom/pcb-design-rules; each finding names the fab's page and the date it was read. `edgeClearance` is edge of copper to the outline: each pad by its real outline turned with it, each track along its whole length (since 0.26.0; before, a pad was a circle of half its long side). Copper wholly outside the outline is listed in `outsideOutline`, not measured; `measuredHow` says what each measure is | | `impedance` | stack | the track width (and pair gap) for a target impedance on each copper layer; `apply` answers `add_rule` arguments | | `cross_check` | sheetParts, board | the sheets' designators against the board's: matched, on the sheets but not the board, on the board but on no sheet | | `current_capacity` | board, stack? | per net and layer, the narrowest copper against the width the current needs (IPC-2221), and the vias a layer change needs |@@ -35,7 +35,7 @@ boards the engine gives the same answers the Altium bridge 0.2.76 gives. | `net_lengths` | board | the routed length of each net (tracks and arcs, by layer, with its vias), the skew of each differential pair (`pairs`, else found by net name: `_P`/`_N`, `+`/`-`) and the spread of each matched-length group against its tolerance (`groups`). From the Altium bridge's lengths.rs | | `placement_check` | board, bodies? | courtyard overlaps (pads and bodies, grown by `marginMm`), parts off or over the edge, pads within `edgeMm` of the edge, parts on mounting holes; `stacked` lists plan-view overlaps where one part sits wholly above the other (a part under a raised molecule: pads apart, no bodies meeting in 3D); `bodiesUsed: false` when no bodies were given; plus a 0-100 score and grade (from kicad-bridge's score_placement): connectors farther than `connectorEdgeMm` from the edge, decoupling capacitors farther than `decouplingMm` from their IC's pin on the same rail, and the ratsnest's length against the board diagonal; a body-less SMD test point counts as flat, so it can sit stacked under a raised module | | `plan_fanout` | board, stack?, rules? | the fanout of a BGA or QFN/QFP (`ref`): pitch and package from its pads; a BGA's outer ring escapes on the surface and each inner ball takes a dogbone via, or a via in the pad when the dogbone does not fit (`style` auto); a perimeter pad takes an outward stub, with a via at its end for ground or `viaPerimeter`, and an exposed pad a via grid. `calls` are route_net arguments, one per net; `conflicts` lists each via and stub closer than the clearance to another net's pad, track, arc or via anywhere on the board. A pin its net's copper already reaches is skipped (`includeRouted` plans it anyway), the exposed-pad grid keeps clear of holes already there, and `crossesPours` names other nets' pours the plan runs into (repour before DRC). From the KiCad bridge's place_tools |-| `plan_route` | board, rules? | a path between two pads of a net (`from`, `to` as Ref.Pad) on any listed copper `layers`, with through vias between them: a bounded orthogonal A* on `gridMm`, width and via from the args, else the board's width and via rules (`planner.widthFrom`, `viaFrom`), keeping `widthMm/2` + the board's strictest board-wide copper clearance rule from other nets' copper (pads by their real outline), inside the outline, no via in a pad; a through via is checked on every copper layer of the board (`planner.viasCheckedOn`), not only the planned ones. `routeNet` is route_net's arguments, unchanged. Pours are not obstacles (repour after), but `crossesPours` names each other net's pour the route runs through, since that can split it; `avoidPours: true` keeps the route out of them (or a list of nets: out of theirs only), and `pourCost` makes a mm inside one cost 1 + pourCost mm, a preference where a hard block finds no path; a pour that holds the route's own end pad is exempt and named (`planner.avoidExempt`); with no path, `ends` names the avoided pours at each end pad and whether they are exempt, and `withoutAvoid` says whether a path exists through them. The grid path is smoothed to straight and 45-degree segments where they keep the same clearance (`smooth: false` keeps it) |+| `plan_route` | board, rules? | a path between two pads of a net (`from`, `to` as Ref.Pad) on any listed copper `layers`, with through vias between them: a bounded orthogonal A* on `gridMm`, width and via from the args, else the board's width and via rules (`planner.widthFrom`, `viaFrom`), keeping `widthMm/2` + the board's strictest board-wide copper clearance rule from other nets' copper (pads by their real outline), inside the outline, no via in a pad, and out of the board model's `keepouts` (a keepout that forbids tracks is an obstacle on its layers for tracks and vias; one that forbids only vias keeps vias out; `planner.keepouts` counts them, and with no path `keepoutsInTheWay` names those between the pads); a through via is checked on every copper layer of the board (`planner.viasCheckedOn`), not only the planned ones. `routeNet` is route_net's arguments, unchanged. Pours are not obstacles (repour after), but `crossesPours` names each other net's pour the route runs through, since that can split it; `avoidPours: true` keeps the route out of them (or a list of nets: out of theirs only), and `pourCost` makes a mm inside one cost 1 + pourCost mm, a preference where a hard block finds no path; a pour that holds the route's own end pad is exempt and named (`planner.avoidExempt`); with no path, `ends` names the avoided pours at each end pad and whether they are exempt, and `withoutAvoid` says whether a path exists through them. The grid path is smoothed to straight and 45-degree segments where they keep the same clearance (`smooth: false` keeps it) | | `review_board` | board, sheetParts?, rules? | small design-review checks, errors first: placeholder values, single-pin nets, duplicate designators, parts with pads off the outline polygon or near the edge (`edgeMm`), parts with no footprint name, off-grid parts (with `gridMm`); from the sheet parts, missing Mouser/DigiKey/LCSC numbers and datasheets and placeholder comments; from the rules, disabled ones, missing clearance/width/hole-size/short-circuit rules and same-priority ties (rules classed from a standard kind, a descriptor, Altium's ordinal or the rule's own name; `alwaysChecked` names classes a tool always checks, like EAGLE's shorts). `skipped` and `notImplemented` say what was not judged. From the Altium bridge's review.rs | | `route_pair` | board, stack?, rules? | a differential pair planned as one centreline (pad midpoints through `via` waypoints) with each net offset half a pitch to its own side, mitred corners and a `fanMm` fan-out; width and gap given, or from `diffOhms` and the stack. `problems` names a crossing or other copper (pads by outline, routed tracks, vias) closer than the clearance; `routeNet` holds both nets' route_net arguments and `widthRule` the pair's add_rule. From the Altium bridge's pairroute.rs | | `schematic_review` | sheetParts, netlist | every placed pin, with its electrical type, against the compiled netlist: power pins on no net and outputs driving each other (errors); unconnected pins, one-pin nets, inputs nothing drives and IC supplies with no capacitor to ground (warnings; a regulator's switch node on an inductor is no missing capacitor). From the Altium bridge's schreview.rs; plus the design checks from kicad-bridge's design_review and sch_check: I2C lines with no pull-up, reset and enable pins floating or with nothing setting their level, LEDs with no series resistor, regulators missing input or output capacitors, rails with no bulk capacitor, unannotated or doubled designators, no-connect flags on wired pins, and two names on one net (`netlist.names`); each with `message` and `fix`; with the `sheetDrawing` companion (one entry per sheet: wires, buses, junctions, noConnects, labels, pins, symbol boxes, mm, y down) also dangling wire ends (with the nearest pin or label), labels on no wire or pin, and symbols drawn over each other, which are listed in `unread` without it |
bridge-rs/vendor/adom-eda-checks/src/fab.rs+81−18@@ -6,32 +6,50 @@ use serde_json::{json, Map, Value}; fn f(v: &Value) -> f64 { v.as_f64().unwrap_or(0.0) } fn r3(v: f64) -> f64 { (v * 1000.0).round() / 1000.0 } -/// The nearest copper (track, arc, pad, via) to the real outline, edge of copper to the outline's line, mm. Pour-/// boundaries are left out: they are drawn on the edge and the tool pulls the poured copper back by its rules.-pub fn edge_distance(state: &Value) -> Option<(f64, Value)> {+/// The nearest copper (track, pad, via) to the real outline, edge of copper to the outline's line, mm: each pad by its+/// real outline turned with it (copperPoints, else its shape: a rectangle's corners, a stadium's long axis), each track+/// along its whole length, so a pad whose short side faces the edge is not measured by its long side (kicad-bridge#155,+/// standard #32). 0 when copper touches, crosses or lies outside the edge. Pour boundaries are left out: they are drawn+/// on the edge and the tool pulls the poured copper back by its rules.+pub fn edge_distance(state: &Value) -> Option<((f64, Value), Vec<Value>)> {+ use crate::route::{inside, pad_shape, seg_seg, Shape}; let ring = crate::coppermap::outline_ring(state); if ring.len() < 3 { return None; }- let seg = |x: f64, y: f64| -> f64 {- (0..ring.len()).map(|k| {- let (a, b) = (ring[k], ring[(k + 1) % ring.len()]);- let (dx, dy) = (b.0 - a.0, b.1 - a.1);- let l2 = dx * dx + dy * dy;- let t = if l2 > 0.0 { (((x - a.0) * dx + (y - a.1) * dy) / l2).clamp(0.0, 1.0) } else { 0.0 };- ((a.0 + t * dx - x).powi(2) + (a.1 + t * dy - y).powi(2)).sqrt()- }).fold(f64::MAX, f64::min)+ let edges: Vec<((f64, f64), (f64, f64))> = (0..ring.len()).map(|k| (ring[k], ring[(k + 1) % ring.len()])).collect();+ // edge to edge, 0 when the copper touches or crosses the outline+ let to_edge = |s: &Shape| -> f64 {+ match s {+ Shape::Cap(a, b, r) => (edges.iter().map(|e| seg_seg(*a, *b, e.0, e.1)).fold(f64::MAX, f64::min) - r).max(0.0),+ Shape::Poly(pts) => (0..pts.len()).flat_map(|i| { let (a, b) = (pts[i], pts[(i + 1) % pts.len()]); edges.iter().map(move |e| seg_seg(a, b, e.0, e.1)) })+ .fold(f64::MAX, f64::min),+ } }; let copper = |l: &Value| l.as_str().map(|s| s.ends_with(".Cu")).unwrap_or(false);- let mut pts: Vec<(f64, f64, f64, Value)> = Vec::new();+ let mut items: Vec<(Shape, (f64, f64), Value)> = Vec::new(); for t in state["tracks"].as_array().cloned().unwrap_or_default().iter().filter(|t| copper(&t["layer"])) {- for p in [&t["start"], &t["end"]] { pts.push((f(&p["x"]), f(&p["y"]), f(&t["width"]) / 2.0, json!({"track": t["net"], "layer": t["layer"]}))); }+ let (a, b) = ((f(&t["start"]["x"]), f(&t["start"]["y"])), (f(&t["end"]["x"]), f(&t["end"]["y"])));+ // a track given by its start only (a single point) is measured there+ let b = if t["end"].is_object() { b } else { a };+ items.push((Shape::Cap(a, b, f(&t["width"]) / 2.0), a, json!({"track": t["net"], "layer": t["layer"]})));+ }+ for v in state["vias"].as_array().cloned().unwrap_or_default() {+ let c = (f(&v["position"]["x"]), f(&v["position"]["y"]));+ items.push((Shape::Cap(c, c, f(&v["size"]) / 2.0), c, json!({"via": v["net"]}))); }- for v in state["vias"].as_array().cloned().unwrap_or_default() { pts.push((f(&v["position"]["x"]), f(&v["position"]["y"]), f(&v["size"]) / 2.0, json!({"via": v["net"]}))); } for p in state["pads"].as_array().cloned().unwrap_or_default() { let (rf, nm) = (p["ref"].as_str().unwrap_or(""), p["name"].as_str().unwrap_or(""));- pts.push((f(&p["x"]), f(&p["y"]), f(&p["sizeX"]).max(f(&p["sizeY"])) / 2.0, json!({"pad": if rf.is_empty() { nm.to_string() } else { format!("{rf}.{nm}") }})));+ items.push((pad_shape(&p), (f(&p["x"]), f(&p["y"])), json!({"pad": if rf.is_empty() { nm.to_string() } else { format!("{rf}.{nm}") }}))); }- pts.into_iter().map(|(x, y, half, mut what)| { what["at"] = json!([r3(x), r3(y)]); (r3(seg(x, y) - half), what) })- .min_by(|a, b| a.0.partial_cmp(&b.0).unwrap())+ // copper wholly outside the outline (a part parked beside the board) is listed apart, not measured as 0+ let mut outside = Vec::new();+ let near = items.into_iter().filter_map(|(s, c, mut what)| {+ // the nearest point of a track is not always its start: name the start anyway, it identifies the track+ what["at"] = json!([r3(c.0), r3(c.1)]);+ let d = r3(to_edge(&s));+ if d > 0.0 && !inside(c, &ring) { outside.push(what); return None; }+ Some((d, what))+ }).min_by(|a, b| a.0.partial_cmp(&b.0).unwrap())?;+ Some((near, outside)) } /// The smallest of each feature with where it is. Pure, for the tests.@@ -59,7 +77,11 @@ pub fn measure(state: &Value) -> Map<String, Value> { if let Some((x0, y0, x1, y1)) = crate::geom::outline_bbox(state) { m.insert("boardSize".into(), json!({"mm": [r3(x1 - x0), r3(y1 - y0)]})); let _ = (x0, y0, x1, y1);- if let Some((d, mut at)) = edge_distance(state) { at["mm"] = json!(d); m.insert("edgeClearance".into(), at); }+ if let Some(((d, mut at), out)) = edge_distance(state) {+ at["mm"] = json!(d);+ m.insert("edgeClearance".into(), at);+ if !out.is_empty() { m.insert("outsideOutline".into(), json!({"count": out.len(), "items": out.iter().take(10).collect::<Vec<_>>()})); }+ } } // drilled holes: the largest, and the closest pair edge to edge (via to via, and any pair with a pad hole) let mut holes: Vec<(f64, f64, f64, bool, Value)> = vias.iter().map(|v| (f(&v["position"]["x"]), f(&v["position"]["y"]), f(&v["drill"]), false, json!({"via": v["net"], "at": [v["position"]["x"], v["position"]["y"]]}))).collect();@@ -252,6 +274,7 @@ pub fn fab_check(input: &Value) -> Value { json!({"success": true, "fab": fab, "measured": meas, "limitsChecked": limits.keys().collect::<Vec<_>>(), "outsideLimits": fails, "notChecked": unseen, "fits": if limits.is_empty() { Value::Null } else { json!(fails.is_empty()) }, "costlierOrBelowRecommended": [],+ "measuredHow": {"edgeClearance": "the shortest distance from any copper's edge to the board outline: each pad by its real outline turned with it (copperPoints, else a rectangle's corners or a stadium's long axis; a roundrect counts as its rectangle, which errs on the safe side), each track along its length less half its width, each via less half its size. 0 when copper touches or crosses the outline; copper wholly outside it (a part parked beside the board) is left out and listed in measured.outsideOutline. Pours are left out."}, "_hint": if limits.is_empty() { "Measured only. Pass a fab's record from adom/pcb-design-rules as fab, or limits:{minTrack, minClearance, minViaDrill, minViaDiameter, minViaAnnularRing, minPadHole, minPadAnnularRing, minSmdPad, minEdgeClearance, minHoleToHoleVia, minHoleToHolePad, maxDrill, minSilkLine, minSilkText, maxLayers, minBoardMm:[w,h], maxBoardMm:[w,h]} in mm, to check them." } else { "outsideLimits names each feature below the fab's limit, where it is, and the page the limit came from. notChecked lists limits the input gave nothing to measure against (pass rules, stack or silk). Read fab.notes: costlier options and recommended sizes are there. Fix the board (set_track_width, add_rule, a footprint change) or choose the fab's advanced service; then run run_drc." }}) }@@ -277,6 +300,46 @@ mod tests { assert_eq!(m["boardSize"]["mm"], json!([50.0, 30.0])); } + fn edge(pad: Value) -> f64 {+ let b = json!({"pads": [pad], "outline": [[0, 0], [20, 0], [20, 10], [0, 10]]});+ measure(&b)["edgeClearance"]["mm"].as_f64().unwrap()+ }++ #[test]+ fn a_pad_is_measured_to_the_edge_by_its_real_outline() {+ // kicad-bridge#155 (standard #32): a SOT-23-6 pad, 1.325 x 0.6 mm, 0.5 mm from the edge whichever way it is turned;+ // the old circle of half the long side said 0.138 for the turned one+ let sot = |x: f64, y: f64, rot: f64| json!({"ref": "U1", "name": "1", "x": x, "y": y, "sizeX": 1.325, "sizeY": 0.6, "rotation": rot, "shape": "rect", "drill": 0.0});+ assert!((edge(sot(18.8375, 5.0, 0.0)) - 0.5).abs() < 1e-3, "rotation 0, right edge");+ assert!((edge(sot(19.2, 5.0, 90.0)) - 0.5).abs() < 1e-3, "rotation 90, right edge");+ assert!((edge(sot(5.0, 9.2, 0.0)) - 0.5).abs() < 1e-3, "rotation 0, top edge");+ assert!((edge(sot(5.0, 8.8375, 90.0)) - 0.5).abs() < 1e-3, "rotation 90, top edge");+ // a 1 mm square turned 45 degrees reaches 0.707 toward the edge: 1.0 - 0.707, not 0.5 (a real 0.3 mm violation passed)+ let sq = json!({"ref": "U2", "name": "1", "x": 19.0, "y": 5.0, "sizeX": 1.0, "sizeY": 1.0, "rotation": 45.0, "shape": "rect", "drill": 0.0});+ assert!((edge(sq) - 0.293).abs() < 1e-3);+ // a stadium (round, 1.6 x 0.8) turned 90 degrees: its short side faces the right edge+ let oval = json!({"ref": "J1", "name": "1", "x": 19.0, "y": 5.0, "sizeX": 1.6, "sizeY": 0.8, "rotation": 90.0, "shape": "round", "drill": 0.8});+ assert!((edge(oval) - 0.6).abs() < 1e-3);+ // copper hanging over the edge is 0, never a negative distance+ assert_eq!(edge(sot(20.0, 5.0, 0.0)), 0.0);+ // a part parked beside the board is listed apart, not measured+ let b = json!({"pads": [sot(18.8375, 5.0, 0.0), sot(30.0, 5.0, 0.0)], "outline": [[0, 0], [20, 0], [20, 10], [0, 10]]});+ let m = measure(&b);+ assert!((m["edgeClearance"]["mm"].as_f64().unwrap() - 0.5).abs() < 1e-3);+ assert_eq!(m["outsideOutline"]["count"], json!(1));+ }++ #[test]+ fn a_track_is_measured_along_its_length_not_at_its_ends() {+ // an L-shaped board: the track's ends are 1 mm inside, but it passes the inner corner at (10, 5)+ let b = json!({"tracks": [{"width": 0.2, "net": "A", "layer": "F.Cu", "start": {"x": 9.0, "y": 4.0}, "end": {"x": 11.0, "y": 6.0}}],+ "outline": [[0, 0], [20, 0], [20, 10], [10, 10], [10, 5], [0, 5]]});+ assert_eq!(measure(&b)["edgeClearance"]["mm"], json!(0.0));+ let b = json!({"tracks": [{"width": 0.2, "net": "A", "layer": "F.Cu", "start": {"x": 2.0, "y": 2.0}, "end": {"x": 8.0, "y": 2.0}}],+ "outline": [[0, 0], [20, 0], [20, 10], [10, 10], [10, 5], [0, 5]]});+ assert_eq!(measure(&b)["edgeClearance"]["mm"], json!(1.9));+ }+ #[test] fn arc_edges_count_toward_the_board_size() { let b = json!({"outline": [[0, 0], [10, 0]], "outlineEdges": [{"kind": "arc", "center": [5.0, 0.0], "radius": 5.0, "angle1": 0.0, "angle2": 180.0}]});
bridge-rs/vendor/adom-eda-checks/src/route.rs+71−3@@ -93,6 +93,32 @@ pub(crate) fn pad_layers(p: &Value, all: &[String]) -> Vec<String> { if l == "*.Cu" || f(&p["drill"]) > 0.0 { all.to_vec() } else { vec![l.to_string()] } } +/// The board model's keepout rule areas as obstacles: (outline, copper layers, what to name) for those that forbid tracks,+/// and for those that forbid vias but allow tracks. `rules.tracks` / `rules.vias` are "not_allowed" (KiCad's word),+/// false or "notAllowed"; a keepout with no rules keeps both out. Layers are copper layer names; "*.Cu" (or none) is+/// every copper layer.+pub(crate) fn keepouts(st: &Value, copper: &[String]) -> (Vec<(Shape, Vec<String>, Value)>, Vec<(Shape, Vec<String>, Value)>) {+ let barred = |k: &Value, what: &str| {+ let r = &k["rules"];+ if !r.is_object() { return true; }+ match &r[what] { Value::Bool(b) => !b, Value::String(s) => { let s = s.to_ascii_lowercase().replace(['_', '-', ' '], ""); s == "notallowed" || s == "forbidden" || s == "no" }, _ => false }+ };+ let (mut tracks, mut vias) = (Vec::new(), Vec::new());+ for (i, k) in st["keepouts"].as_array().cloned().unwrap_or_default().iter().enumerate() {+ let ring: Vec<P> = k["points"].as_array().cloned().unwrap_or_default().iter()+ .map(|q| if q.is_array() { (f(&q[0]), f(&q[1])) } else { (f(&q["x"]), f(&q["y"])) }).collect();+ if ring.len() < 3 { continue; }+ let mut ls: Vec<String> = k["layers"].as_array().map(|a| a.iter().filter_map(|v| v.as_str().map(String::from)).collect())+ .or_else(|| k["layer"].as_str().map(|l| vec![l.to_string()])).unwrap_or_default();+ if ls.is_empty() || ls.iter().any(|l| l.contains('*')) { ls = copper.to_vec(); }+ let (bx0, by0, bx1, by1) = Shape::Poly(ring.clone()).bounds();+ let what = json!({"keepout": k.get("name").cloned().unwrap_or(json!(i)), "box": [r3(bx0), r3(by0), r3(bx1), r3(by1)]});+ if barred(k, "tracks") { tracks.push((Shape::Poly(ring), ls, what)); }+ else if barred(k, "vias") { vias.push((Shape::Poly(ring), ls, what)); }+ }+ (tracks, vias)+}+ /// plan_route: input {board, rules?, args: {net, from, to, widthMm?, layers?, allowVias?, viaSizeMm?, viaDrillMm?, gridMm?, /// viaCost?, clearanceMm?, edgeClearanceMm?, maxNodes?}}. `from` and `to` are pads as Ref.Pad. The width and via come from /// the args, else the board's width and via rules (`rules`), else 0.25 mm and 0.6/0.3; `planner` says which.@@ -193,6 +219,10 @@ pub fn plan_route(input: &Value) -> Value { let c = (f(&v["position"]["x"]), f(&v["position"]["y"])); push(Shape::Cap(c, c, f(&v["size"]) / 2.0), copper.clone()); }+ // keepout rule areas (kicad-bridge#156, standard #33): one that forbids tracks is an obstacle on its layers like other+ // copper, so neither a track nor a via (copper on that layer too) enters it; one that forbids only vias keeps vias out+ let (track_keep, via_keep) = keepouts(&st, &copper);+ for (s, ls, _) in &track_keep { push(s.clone(), ls.clone()); } let all_pads: Vec<Shape> = pads.iter().map(pad_shape).collect(); // the grid: lines every gridMm over the outline, plus lines through both pad centres@@ -237,6 +267,7 @@ pub fn plan_route(input: &Value) -> Value { // a through via: clear on every layer, inside the outline, in no pad let r = via_size / 2.0; edge_ok(a, a, r) && copper.iter().all(|l| clear_on(a, a, r, l)) && all_pads.iter().all(|s| s.dist(a, a) >= r + clearance - 1e-9)+ && via_keep.iter().all(|(s, _, _)| s.dist(a, a) >= r + clearance - 1e-9) } else { edge_ok(a, b, width / 2.0) && clear_on(a, b, width / 2.0, &layers[u.2]) && !(0..pours.len()).any(|i| blocks(i) && pours[i].1 == layers[u.2] && pours[i].2.dist(a, b) < width / 2.0)@@ -289,6 +320,9 @@ pub fn plan_route(input: &Value) -> Value { .map(|i| json!({"net": pours[i].0, "layer": pours[i].1, "exempt": held.contains(&i)})).collect(); json!({"pad": key(p), "avoidedPoursHere": touching}) }).collect();+ // keepouts the straight line between the pads crosses: the likely wall when no path is left+ let in_way: Vec<Value> = track_keep.iter().chain(via_keep.iter()).filter(|(s, ls, _)| ls.iter().any(|l| layers.contains(l)) && s.dist(sp, gp) <= 0.0)+ .map(|(_, ls, what)| { let mut w = what.clone(); w["layers"] = json!(ls); w }).collect(); let walled = near_ends.iter().any(|e| e["avoidedPoursHere"].as_array().map(|a| a.iter().any(|x| x["exempt"] == json!(false))).unwrap_or(false)); // when keeping out of the pours is what fails, say so: plan again through them (fusion-lane #21: VBAT's pour wraps // SW1.2 in a notch it never touches)@@ -301,10 +335,11 @@ pub fn plan_route(input: &Value) -> Value { } let why = if avoid_nets.is_some() && walled { "no legal path: an avoided pour touches an end pad without holding it (avoidedPoursHere), so the route cannot leave the pad without entering it. Try pourCost instead of avoidPours, or drop that net from avoidPours".to_string() } else if !through.is_null() { format!("no path keeps out of the avoided pours: every way between the pads crosses one (a path through them exists: withoutAvoid). Use pourCost to go round them where it can, or drop a net from avoidPours") }+ else if !in_way.is_empty() && seen.len() < max_nodes { format!("no legal path: keepout areas (keepoutsInTheWay) and other copper close every way between the pads. Allow more layers, or move the keepout or a pad") } else { why.to_string() };- return json!({"success": true, "found": false, "reason": why, "expandedNodes": seen.len(), "revision": revision, "ends": near_ends, "withoutAvoid": through,+ return json!({"success": true, "found": false, "reason": why, "expandedNodes": seen.len(), "revision": revision, "ends": near_ends, "withoutAvoid": through, "keepoutsInTheWay": in_way, "planner": {"algorithm": "bounded orthogonal A*", "widthFrom": width_from, "viaFrom": via_from, "gridMm": grid, "layers": layers, "viasCheckedOn": copper, "clearanceMm": clearance, "edgeClearanceMm": edge,- "avoidPours": args["avoidPours"].clone(), "avoidExempt": exempt, "pourCost": pour_cost, "expandedNodes": seen.len()}});+ "avoidPours": args["avoidPours"].clone(), "avoidExempt": exempt, "pourCost": pour_cost, "keepouts": {"noTracks": track_keep.len(), "noVias": via_keep.len()}, "expandedNodes": seen.len()}}); }; let mut path = vec![goal_node]; while let Some(p) = parent.get(path.last().unwrap()) { path.push(*p); }@@ -363,7 +398,7 @@ pub fn plan_route(input: &Value) -> Value { json!({"success": true, "found": true, "lengthMm": r3(length), "vias": vias.len(), "viaAt": vias, "routeNet": {"net": net, "layer": layers[path[0].2], "width": width, "viaSize": via_size, "viaDrill": via_drill, "paths": [way]}, "planner": {"algorithm": if smooth { "bounded orthogonal A*, smoothed to straight and 45-degree segments" } else { "bounded orthogonal A*" }, "widthFrom": width_from, "viaFrom": via_from, "gridMm": grid, "layers": layers, "viasCheckedOn": copper, "clearanceMm": clearance, "edgeClearanceMm": edge,- "avoidPours": args["avoidPours"].clone(), "avoidExempt": exempt, "pourCost": pour_cost, "smooth": smooth, "expandedNodes": seen.len()},+ "avoidPours": args["avoidPours"].clone(), "avoidExempt": exempt, "pourCost": pour_cost, "smooth": smooth, "keepouts": {"noTracks": track_keep.len(), "noVias": via_keep.len()}, "expandedNodes": seen.len()}, "crossesPours": crosses, "avoidPours": args["avoidPours"].clone(), "pourCost": pour_cost, "revision": revision, "_hint": if crosses.is_empty() { "A plan only: pass routeNet to route_net unchanged (with expectedRevision: revision). A layer change is two waypoints at the same point, where route_net places a via. Pours (and a hatched pour's net-less pieces) are not obstacles: repour after placing the route. The path is orthogonal on the grid: a finer gridMm finds tighter paths and searches longer." } else { "A plan only: pass routeNet to route_net unchanged (with expectedRevision: revision). The route runs through the pours in crossesPours: after the repour, check that none of those nets split in two (routing_state's splitNets), or plan again keeping out of them: avoidPours: true (or a list of the nets whose pours to keep out of), or pourCost: 2 to prefer going round them where a way exists. A layer change is two waypoints at the same point, where route_net places a via." }})@@ -382,6 +417,39 @@ mod tests { "tracks": extra_tracks, "arcs": [], "vias": []}) } + fn keepout_board(y0: f64, y1: f64) -> Value {+ // kicad-bridge#156 (standard #33): 30 x 20 mm, a keepout between the pads, tracks and vias not allowed+ json!({"nets": ["SIG"], "revision": "r1", "outline": [[0, 0], [30, 0], [30, 20], [0, 20]],+ "pads": [{"ref": "R1", "name": "1", "x": 5.0, "y": 10.0, "sizeX": 1.0, "sizeY": 1.0, "rotation": 0.0, "shape": "rect", "layer": "F.Cu", "drill": 0.0, "net": "SIG"},+ {"ref": "R2", "name": "1", "x": 25.0, "y": 10.0, "sizeX": 1.0, "sizeY": 1.0, "rotation": 0.0, "shape": "rect", "layer": "F.Cu", "drill": 0.0, "net": "SIG"}],+ "tracks": [], "arcs": [], "vias": [],+ "keepouts": [{"layers": ["F.Cu", "B.Cu"], "points": [[13.0, y0], [17.0, y0], [17.0, y1], [13.0, y1]],+ "rules": {"tracks": "not_allowed", "vias": "not_allowed", "pads": "allowed", "copperpour": "allowed", "footprints": "allowed"}}]})+ }++ #[test]+ fn a_route_goes_round_a_keepout_or_names_it() {+ let r = plan_route(&json!({"board": keepout_board(4.0, 16.0), "args": {"net": "SIG", "from": "R1.1", "to": "R2.1"}}));+ assert_eq!(r["found"], json!(true), "{r}");+ assert_eq!(r["planner"]["keepouts"]["noTracks"], 1);+ // no segment of the plan enters the keepout (x 13..17, y 4..16)+ let way: Vec<P> = r["routeNet"]["paths"][0].as_array().unwrap().iter()+ .map(|w| if w.get("pad").is_some() { if w["pad"] == "R1.1" { (5.0, 10.0) } else { (25.0, 10.0) } } else { (f(&w["x"]), f(&w["y"])) }).collect();+ let keep = Shape::Poly(vec![(13.0, 4.0), (17.0, 4.0), (17.0, 16.0), (13.0, 16.0)]);+ for w in way.windows(2) { assert!(keep.dist(w[0], w[1]) >= 0.125 - 1e-9, "{:?} enters the keepout: {r}", w); }+ assert!(r["lengthMm"].as_f64().unwrap() > 20.0, "it goes round: {r}");+ // a keepout across the whole board leaves no way, and the reply names it+ let none = plan_route(&json!({"board": keepout_board(-1.0, 21.0), "args": {"net": "SIG", "from": "R1.1", "to": "R2.1"}}));+ assert_eq!(none["found"], json!(false), "{none}");+ assert_eq!(none["keepoutsInTheWay"][0]["keepout"], json!(0));+ assert!(none["reason"].as_str().unwrap().contains("keepout"), "{none}");+ // a keepout that forbids only pours is no obstacle+ let mut b = keepout_board(4.0, 16.0);+ b["keepouts"][0]["rules"] = json!({"tracks": "allowed", "vias": "allowed", "copperpour": "not_allowed"});+ let r = plan_route(&json!({"board": b, "args": {"net": "SIG", "from": "R1.1", "to": "R2.1"}}));+ assert!((r["lengthMm"].as_f64().unwrap() - 20.0).abs() < 1e-9, "{r}");+ }+ #[test] fn a_clear_board_is_one_straight_track() { let r = plan_route(&json!({"board": board(json!([])), "args": {"net": "SIG", "from": "U1.1", "to": "J1.1"}}));
bridge-rs/vendor/adom-eda-checks/tests/fixtures.rs+4−1@@ -50,7 +50,10 @@ fn return_path_matches_altium() { #[test] fn fab_check_measures_what_altium_measures() {- same("fab_check", &["measured.boardSize", "measured.clearanceRule", "measured.copperLayers", "measured.counts", "measured.edgeClearance", "measured.holeToHolePad",+ // left out: clearanceRule (no read_rules fixture was captured, so the engine has no rules to read) and edgeClearance+ // (Altium 0.2.76 measured each pad as a circle of half its long side: -0.526 at the Sentinel's J1.1, which sits 0.36 mm+ // inside the edge; the engine measures real outlines since 0.26.0, standard #32)+ same("fab_check", &["measured.boardSize", "measured.copperLayers", "measured.counts", "measured.holeToHolePad", "measured.holeToHoleVia", "measured.largestDrill", "measured.padHole", "measured.smdPad", "measured.track", "measured.viaAnnularRing", "measured.viaDiameter", "measured.viaDrill", "outsideLimits", "limitsChecked"]); }
package.json+1−1@@ -1,6 +1,6 @@ { "slug": "altium-bridge",- "version": "0.2.107",+ "version": "0.2.108", "type": "app", "description": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.", "tags": [
page.json+1−1@@ -4,7 +4,7 @@ "type": "app", "title": "Altium Bridge: AI for Altium Designer", "brief": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.",- "version": "0.2.107",+ "version": "0.2.108", "hero": { "type": "image", "path": "screenshots/hero.png"
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-0.2.107+0.2.108
src/agent/AdomAgent.pas.tmpl+50−4@@ -6223,7 +6223,12 @@ Var Poly : IPCB_Polygon; BO : IPCB_BoardOutline; Seg : TPolySegment;- LT, LA, LV, LP, LC, LG, LO : TStringList;+ LT, LA, LV, LP, LC, LG, LO, LK : TStringList;+ Fl : IPCB_Fill;+ Reg : IPCB_Region;+ Ct : IPCB_Contour;+ KS : String;+ TL : Integer; Own, Pts : String; K, Unrouted, Oid : Integer; PR : TCoordRect;@@ -6232,7 +6237,7 @@ 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; LT := TStringList.Create; LA := TStringList.Create; LV := TStringList.Create; LP := TStringList.Create;- LC := TStringList.Create; LG := TStringList.Create; LO := TStringList.Create;+ LC := TStringList.Create; LG := TStringList.Create; LO := TStringList.Create; LK := TStringList.Create; Unrouted := 0; BIt := Board.BoardIterator_Create; BIt.AddFilter_ObjectSet(MkSet(eTrackObject, eArcObject, eViaObject, ePadObject, eComponentObject, ePolyObject, eConnectionObject));@@ -6246,6 +6251,10 @@ Begin If Oid = eTrackObject Then Begin Trk := Prim;+ { a keepout (marked, or on the Keep-Out layer, a footprint's own included) is an obstacle for plan_route }+ TL := Trk.Layer;+ If (TL = eKeepOutLayer) Or Trk.IsKeepout Then+ LK.Add('["t",' + IntToStr(TL) + ',' + IntToStr(Trk.x1) + ',' + IntToStr(Trk.y1) + ',' + IntToStr(Trk.x2) + ',' + IntToStr(Trk.y2) + ',' + IntToStr(Trk.Width) + ']'); If Not Trk.InComponent Then LT.Add('[' + IntToStr(Trk.x1) + ',' + IntToStr(Trk.y1) + ',' + IntToStr(Trk.x2) + ',' + IntToStr(Trk.y2) + ',' + IntToStr(Trk.Width) + ',' + IntToStr(Trk.Layer) + ',' + NetOf(Trk) + ']');@@ -6253,6 +6262,10 @@ Begin Else If Oid = eArcObject Then Begin Arc := Prim;+ TL := Arc.Layer;+ If (TL = eKeepOutLayer) Or Arc.IsKeepout Then+ LK.Add('["a",' + IntToStr(TL) + ',' + IntToStr(Arc.XCenter) + ',' + IntToStr(Arc.YCenter) + ',' + IntToStr(Arc.Radius) + ',' ++ IntToStr(Round(Arc.StartAngle * 1000)) + ',' + IntToStr(Round(Arc.EndAngle * 1000)) + ',' + IntToStr(Arc.LineWidth) + ']'); If Not Arc.InComponent Then LA.Add('[' + IntToStr(Arc.XCenter) + ',' + IntToStr(Arc.YCenter) + ',' + IntToStr(Arc.Radius) + ',' + IntToStr(Round(Arc.StartAngle * 1000)) + ',' + IntToStr(Round(Arc.EndAngle * 1000)) + ',' +@@ -6301,6 +6314,39 @@ Begin Prim := BIt.NextPCBObject; End; Board.BoardIterator_Destroy(BIt);+ { keepout fills and regions: few on any board, so their own walk }+ BIt := Board.BoardIterator_Create;+ BIt.AddFilter_ObjectSet(MkSet(eFillObject, eRegionObject));+ BIt.AddFilter_LayerSet(AllLayers);+ BIt.AddFilter_Method(eProcessAll);+ Prim := BIt.FirstPCBObject;+ While Prim <> Nil Do+ Begin+ TL := Prim.Layer;+ If (TL = eKeepOutLayer) Or Prim.IsKeepout Then+ Begin+ If Prim.ObjectId = eFillObject Then+ Begin+ Fl := Prim;+ LK.Add('["f",' + IntToStr(TL) + ',' + IntToStr(Fl.X1Location) + ',' + IntToStr(Fl.Y1Location) + ',' + IntToStr(Fl.X2Location) + ',' ++ IntToStr(Fl.Y2Location) + ',' + IntToStr(Round(Fl.Rotation * 1000)) + ']');+ End+ Else+ Begin+ Reg := Prim;+ Ct := Reg.MainContour;+ KS := '';+ For K := 0 To Ct.Count - 1 Do+ Begin+ If K > 0 Then KS := KS + ',';+ KS := KS + '[' + IntToStr(Ct.x[K]) + ',' + IntToStr(Ct.y[K]) + ']';+ End;+ LK.Add('["r",' + IntToStr(TL) + ',[' + KS + ']]');+ End;+ End;+ Prim := BIt.NextPCBObject;+ End;+ Board.BoardIterator_Destroy(BIt); BO := Board.BoardOutline; If BO <> Nil Then For K := 0 To BO.PointCount - 1 Do@@ -6315,8 +6361,8 @@ Begin Result := '{' + JRaw('ok','true') + ',' + JStr('file', Board.FileName) + ',' + JRaw('coordPerMil','10000') + ',' + JRaw('tracks', JoinList(LT)) + ',' + JRaw('arcs', JoinList(LA)) + ',' + JRaw('vias', JoinList(LV)) + ',' + JRaw('pads', JoinList(LP)) + ',' + JRaw('comps', JoinList(LC)) + ',' + JRaw('polys', JoinList(LG)) + ',' +- JRaw('outline', JoinList(LO)) + ',' + JRaw('unrouted', IntToStr(Unrouted)) + '}';- LT.Free; LA.Free; LV.Free; LP.Free; LC.Free; LG.Free; LO.Free;+ JRaw('outline', JoinList(LO)) + ',' + JRaw('keepouts', JoinList(LK)) + ',' + JRaw('unrouted', IntToStr(Unrouted)) + '}';+ LT.Free; LA.Free; LV.Free; LP.Free; LC.Free; LG.Free; LO.Free; LK.Free; End; { edit_board: a batch of copper and placement edits in ONE PreProcess/PostProcess (one undo
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "altium", "displayName": "Altium Designer",- "version": "0.2.107",+ "version": "0.2.108", "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",