app
KiCad - the KiCad Bridge
Public Made by Adomby adom
Drive your own KiCad from an AI, in the background: open every editor, read the whole board as data (the EDA Bridge Standard board model), stack-up, part heights, netlists, place, route, pour, DRC and exports.
← Commit history
1.0.7: 1.0.7: kicad_remove_zone (zones by id, one Undo step); kicad_zone_state names zone types (copper, keepout, teardrop)
1 file changed
+8−3
rust/crates/kicad-core/src/zones.rs+8−3@@ -354,6 +354,8 @@ pub struct ZoneRead { pub priority: u32, pub filled: bool, pub rule_area: bool,+ /// ZoneType: 1 copper, 2 graphical, 3 rule area, 4 teardrop (KiCad makes those itself at pad entries).+ pub zone_type: u32, pub outline_area_mm2: f64, /// (layer id, polygon count, filled area in mm2) per filled layer. pub fills: Vec<(i32, usize, f64)>,@@ -444,7 +446,10 @@ pub fn decode_zone(b: &[u8]) -> Result<ZoneRead, String> { } } }- (2, 0) => z.rule_area = varint_value(f.data)? == 3,+ (2, 0) => {+ z.zone_type = varint_value(f.data)? as u32;+ z.rule_area = z.zone_type == 3;+ } (7, 2) => z.rule_area = true, (3, 0) => z.layers.push(varint_value(f.data)? as i32), (3, 2) => {@@ -514,7 +519,7 @@ pub fn state_json(zones: &[ZoneRead], board: &Board) -> Value { .collect(); list.push(json!({ "id": z.id, "name": z.name, "net": z.net, "layers": z.layers.iter().map(|l| copper_layer_name(*l)).collect::<Vec<_>>(),- "type": if z.rule_area { "keepout" } else { "copper" },+ "type": match z.zone_type { 3 => "keepout", 4 => "teardrop", 2 => "graphical", _ => "copper" }, "priority": z.priority, "filled": z.filled, "outlineAreaMm2": round2(z.outline_area_mm2), "fills": fills, })); }@@ -586,7 +591,7 @@ mod tests { #[test] fn state_sums_fill_area_per_layer() { let b = board();- let z = ZoneRead { id: "a".into(), name: "GND pour".into(), net: "GND".into(), layers: vec![3], priority: 0, filled: true, rule_area: false, outline_area_mm2: 100.0, fills: vec![(3, 2, 80.0)] };+ let z = ZoneRead { id: "a".into(), name: "GND pour".into(), net: "GND".into(), layers: vec![3], priority: 0, filled: true, rule_area: false, zone_type: 1, outline_area_mm2: 100.0, fills: vec![(3, 2, 80.0)] }; let v = state_json(&[z], &b); assert_eq!(v["filledAreaByLayerMm2"]["F.Cu"], json!(80.0)); assert_eq!(v["filledCoverageByLayerPercent"]["F.Cu"], json!(4.0));