← Commit history

2.47.9: a named np_thru_hole wired to a symbol pin stays a pad (#36 follow-up on 2.47.8); GH 2509eb6

Colby Knox ·90d0deae80 · ·parent 13d2436
8 files changed +54−6
CHANGELOG.md+3
@@ -1,5 +1,8 @@ # Changelog +## 2.47.9 (2026-10-28)+- A named non-plated pad that a symbol pin connects to (an `MP` pin on a mounting hole) stays a pad, with `WARN: [npth-wired]`. Under 2.47.8 it became a `<hole>`, so the pin's connect pointed at a pad that no longer existed and lint and validate failed. EAGLE connects pins to pads, never to holes. Every non-plated pad that no pin reaches is still a `<hole>`. (#36)+ ## 2.47.8 (2026-10-28) - `generate` keeps a footprint's `np_thru_hole` pads as EAGLE `<hole>` elements, in the main package and every package variant. They used to be dropped, so guide posts, board pegs and holddown holes were missing in Fusion (hr911130a, an ET60S connector, 0741640110), and a named one such as an `MP` pad came out as a plated `<pad>` with copper the footprint does not have. Positions use the pads' y-flip, and a drill offset turns with the pad. An oval slot is drilled at its short width, since a `<hole>` is round, with the slot outline on layer 46 Milling and a `WARN` naming it. (#36, Caleb) 
Cargo.lock+1−1
@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"  [[package]] name = "adom-lbr"-version = "2.47.8"+version = "2.47.9" dependencies = [  "altium-codec",  "anyhow",
Cargo.toml+1−1
@@ -1,6 +1,6 @@ [package] name = "adom-lbr"-version = "2.47.8"+version = "2.47.9" edition = "2021" description = "adom-lbr generator / EDA translator: the canonical adom-lbr JSON is the hub, with native converters to Altium (.SchLib/.PcbLib/.IntLib), EAGLE/Fusion (.lbr), and KiCad. Altium output is written natively — no Altium needed at conversion time." 
VERSION+1−1
@@ -1 +1 @@-2.47.8+2.47.9
bin/adom-lbr
⋯ 1 unchanged line ⋯
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "adom-lbr",-  "version": "2.47.8",+  "version": "2.47.9",   "type": "app",   "description": "adom-lbr \u2014 the EDA library translator. Bring a component in from any supported EDA tool and convert it to any other (KiCad \u21c4 Altium \u21c4 EAGLE/Fusion) through one canonical adom-lbr JSON \u2014 symbol + footprint + 3D + pin\u2194pad map. Altium is written natively (no Altium needed). Includes the adom-lbr Manager: browse wiki components and view symbol/footprint/3D + the per-EDA layer stackup.",   "dependencies": {},
page.json+2−2
@@ -1,6 +1,6 @@ {   "slug": "adom-lbr",-  "version": "2.47.8",+  "version": "2.47.9",   "type": "app",   "description": "adom-lbr — the EDA library translator. Bring a component in from any supported EDA tool and convert it to any other (KiCad ⇄ Altium ⇄ EAGLE/Fusion) through one canonical adom-lbr JSON — symbol + footprint + 3D + pin↔pad map. Altium is written natively (no Altium needed). Includes the adom-lbr Manager: browse wiki components and view symbol/footprint/3D + the per-EDA layer stackup.",   "dependencies": {},@@ -89,4 +89,4 @@       "label": "Browse parts"     }   ]-}\ No newline at end of file+}
src/main.rs+45
@@ -1360,6 +1360,28 @@ fn parse_mod_holes(km: &str) -> Vec<ModHole> {     holes } +/// A named `np_thru_hole` pad that a symbol pin wires to is rewritten as `thru_hole`, so+/// it stays a connectable pad (with the copper ring EAGLE gives every pad) instead of a+/// `<hole>` the pin's connect could not reach. Every other NPTH is left for `<hole>`.+fn keep_wired_npth(km: &str, wired: &std::collections::HashSet<String>) -> String {+    let head = regex_lite::Regex::new(r#"\(pad\s+(?:"([^"]+)"|([^\s"()]+))\s+np_thru_hole\b"#).unwrap();+    let mut kept = Vec::new();+    let out = head.replace_all(km, |c: &regex_lite::Captures| {+        let name = c.get(1).or_else(|| c.get(2)).map(|m| m.as_str()).unwrap_or("");+        if wired.contains(name) {+            kept.push(name.to_string());+            c[0].replacen("np_thru_hole", "thru_hole", 1)+        } else {+            c[0].to_string()+        }+    }).into_owned();+    if !kept.is_empty() {+        kept.dedup();+        eprintln!("WARN: [npth-wired] non-plated pad(s) {} are wired to symbol pins, so they stay plated pads (EAGLE connects pins to pads, not holes); drop the pin from the symbol, or map it elsewhere with --pin-map, to get a bare hole.", kept.join(", "));+    }+    out+}+ /// EAGLE for the footprint's non-plated holes: one `<hole>` each. EAGLE's hole is round /// only, so an oval (slotted) drill becomes a hole of its SHORT width at the slot centre, /// which never cuts outside the slot, plus the slot outline on layer 46 Milling, which is@@ -2457,6 +2479,15 @@ pub(crate) fn generate_lbr(sym: &ParsedSymbol, fp_content: Option<&str>, symbol_ }  pub(crate) fn generate_lbr_gates(sym: &ParsedSymbol, fp_content: Option<&str>, symbol_art: Option<&SymbolArt>, symbol_art_scale: f64, pin_map: &std::collections::HashMap<String, String>, part_attrs: &[(String, String)], alts: &[AltGate], variants: &[PackageVariant]) -> Result<String, String> {+    // A named np_thru_hole that a symbol pin wires to stays a pad: EAGLE connects every+    // pin to a pad, and a <hole> cannot be connected.+    let wired: std::collections::HashSet<String> = sym.pins.iter().chain(alts.iter().flat_map(|a| a.sym.pins.iter()))+        .map(|p| pin_map.get(&p.number).cloned().unwrap_or_else(|| p.number.clone())).collect();+    let fp_owned = fp_content.map(|km| keep_wired_npth(km, &wired));+    let fp_content = fp_owned.as_deref();+    let variants_owned: Vec<PackageVariant> = variants.iter()+        .map(|v| PackageVariant { km: keep_wired_npth(&v.km, &wired), ..v.clone() }).collect();+    let variants = &variants_owned[..];     // An explicitly supplied zero-pad footprint is not an absent footprint.     // Reject this unsupported off-board export before inventing copper or writing output.     if fp_content.is_some_and(|km| parse_mod_pads(km).is_empty()) {@@ -5537,6 +5568,20 @@ mod npth_tests {         assert!(lint_lbr(&xml).errors.is_empty(), "{:?}", lint_lbr(&xml).errors);     } +    #[test]+    fn a_named_npth_wired_to_a_symbol_pin_stays_a_connectable_pad() {+        let sym_src = SYM.replace(r#"(pin output line (at 15.24 -2.00 180) (length 2.54) (name "B") (number "2"))"#,+            r#"(pin output line (at 15.24 -2.00 180) (length 2.54) (name "B") (number "2"))+      (pin passive line (at 15.24 -4.54 180) (length 2.54) (name "MP") (number "MP"))"#);+        let sym = parse_kicad_sym(&sym_src, None).unwrap();+        assert_eq!(sym.pins.len(), 3);+        let xml = generate_lbr(&sym, Some(FP), None, 0.38, &Default::default(), &[]).unwrap();+        assert!(xml.contains(r#"<pad name="MP" x="2.5000" y="-1.5000""#), "the wired MP stays a pad: {xml}");+        assert!(!xml.contains(r#"<hole x="2.5000""#), "and is not also a hole");+        assert_eq!(xml.matches("<hole ").count(), 2, "the unwired NPTHs are still holes");+        assert!(lint_lbr(&xml).errors.is_empty(), "{:?}", lint_lbr(&xml).errors);+    }+     #[test]     fn a_drill_offset_turns_with_the_pad() {         let km = r#"(footprint "T"