← Commit history
CHANGELOG.md+4
@@ -1,5 +1,9 @@ # Changelog +## 2.47.14 (2026-12-04)+- Slotted drills are kept. `import-kicad` used to turn `(drill oval 0.6 1.7)` into a round 1.7 mm hole, larger than its own 1.0 mm wide pad. The hub JSON now carries the slot as `drill_slot_mm: [W, H]` (in the pad's own frame), with `drill_mm` set to the slot's width so older readers stay inside the slot. KiCad export writes `(drill oval W H)`, and the Altium libraries get a real slot hole (hole size = width, slot length and pad-relative rotation). In EAGLE a pad drill is round only, so `generate` drills the slot's width, draws the slot on layer 46 Milling, and prints `WARN: [slot-drill]`. (#41)+- Non-plated holes stay non-plated in Altium. Pads that are `plated: false` (KiCad `np_thru_hole` pegs and mounting holes) are written with Plated = False; they used to come out plated. `import-altium` reads both the plated flag and slots back. (#41)+ ## 2.47.13 (2026-12-03) - `assemble-altium` no longer gives parts on a common package the first part's 3D model. Parts share one footprint only when the land pattern and the 3D model bytes both match. A part with the same land pattern but its own model (or no model) gets its own footprint named `<footprint>_<MPN>`, listed in `renamed` with the reason, for example "same footprint as LM317, with this part's own 3D model". Before, five TO-220 regulators and four SOIC-8 parts came out with 2 footprints and 2 bodies; now 9 and 9. `deduped` lists only true folds. A footprint name used by different geometry is also renamed `<name>_<MPN>` (it was `<name>@2`). 
Cargo.lock+1−1
@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"  [[package]] name = "adom-lbr"-version = "2.47.13"+version = "2.47.14" dependencies = [  "altium-codec",  "anyhow",
Cargo.toml+1−1
@@ -1,6 +1,6 @@ [package] name = "adom-lbr"-version = "2.47.13"+version = "2.47.14" 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.13+2.47.14
bin/adom-lbr
⋯ 1 unchanged line ⋯
crates/altium-codec/src/altium_decode.rs+11−3
@@ -741,6 +741,15 @@ fn decode_pad(blocks: &[&[u8]]) -> Option<Pad> {         _ => "rect",     };     let rotation = if pd.len() >= 60 { le_f64(pd, 52) } else { 0.0 };+    // Byte 60 is Plated (0 on a non-plated hole); sub-block 6, when present, holds+    // the hole shape at 262 (2 = slot), the slot length at 263 and the slot's+    // rotation relative to the pad at 267. The hole size at 45 is the slot width.+    let plated = (hole > 0.0 && pd.len() > 60).then(|| pd[60] != 0);+    let drill_slot_mm = blocks.get(5).filter(|s6| s6.len() >= 275 && s6[262] == 2 && hole > 0.0).map(|s6| {+        let len = le_u32(s6, 263) as f64 * ALTIUM_UNIT_MM;+        let along_y = (le_f64(s6, 267).rem_euclid(180.0) - 90.0).abs() < 45.0;+        if along_y { [hole, len] } else { [len, hole] }+    });     Some(Pad {         number,         x_mm: x,@@ -750,14 +759,13 @@ fn decode_pad(blocks: &[&[u8]]) -> Option<Pad> {         drill_mm: hole,         rotation,         shape: shape.to_string(),-        // The plated flag byte in the Altium pad record isn't calibrated yet —-        // unknown, so leave None (treated as plated downstream).-        plated: None,+        plated,         // Manual mask/paste expansion (mode byte 2) reads back as the signed         // margin; rule mode (1) means inherit, so None.         mask_margin_mm: manual_expansion(pd, 90, 102),         paste_margin_mm: manual_expansion(pd, 86, 101),         paste_margin_ratio: None,+        drill_slot_mm,     }) } 
crates/altium-codec/src/kicad.rs+16−6
@@ -390,12 +390,21 @@ pub(crate) fn import_footprint(text: &str) -> Result<Footprint> {         let at = p.child("at").map(|a| a.nums()).unwrap_or_default();         let size = p.child("size").map(|a| a.nums()).unwrap_or_default();         let rot = at.get(2).copied().unwrap_or(0.0);-        // (drill d) or (drill oval w h) — take the larger axis of a slot so-        // the hole isn't undersized (full slot support is a future field).-        let drill = p-            .child("drill")-            .map(|d| d.nums().into_iter().fold(0.0_f64, f64::max))-            .unwrap_or(0.0);+        // (drill d) or (drill oval w [h]). A slot keeps both axes; its round+        // stand-in is the narrow side, never the length, which would cut+        // through the pad ring (a 0.6 x 1.7 slot became a 1.7 mm round hole in a+        // 1.0 mm wide pad).+        let drill_node = p.child("drill");+        let is_oval = drill_node.is_some_and(|d| d.items().iter().any(|i| matches!(i, Sx::Atom(a) if a == "oval")));+        let drill_nums = drill_node.map(|d| d.nums()).unwrap_or_default();+        let drill_slot = match (is_oval, drill_nums.first(), drill_nums.get(1)) {+            (true, Some(&w), Some(&h)) if (w - h).abs() > 1e-9 && w > 0.0 && h > 0.0 => Some([w, h]),+            _ => None,+        };+        let drill = match drill_slot {+            Some([w, h]) => w.min(h),+            None => drill_nums.first().copied().unwrap_or(0.0),+        };         let kshape = match shape.as_str() {             "circle" => "circle",             "oval" => "oval",@@ -418,6 +427,7 @@ pub(crate) fn import_footprint(text: &str) -> Result<Footprint> {             mask_margin_mm: p.child("solder_mask_margin").and_then(|m| m.nums().first().copied()),             paste_margin_mm: p.child("solder_paste_margin").and_then(|m| m.nums().first().copied()),             paste_margin_ratio: p.child("solder_paste_margin_ratio").and_then(|m| m.nums().first().copied()),+            drill_slot_mm: if is_th { drill_slot } else { None },         });     } 
crates/altium-codec/src/kicad_export.rs+4−1
@@ -327,7 +327,10 @@ pub fn export_kicad_footprint_for(fp: &Footprint, ver: KicadVersion) -> String {             esc(&pad.number), n(pad.w_mm), n(pad.h_mm)         ));         if thru {-            s.push_str(&format!(" (drill {})", n(pad.drill_mm)));+            match pad.drill_slot_mm {+                Some([w, h]) => s.push_str(&format!(" (drill oval {} {})", n(w), n(h))),+                None => s.push_str(&format!(" (drill {})", n(pad.drill_mm))),+            }         }         s.push_str(&format!(" (layers {layers})"));         if shape == "roundrect" {
crates/altium-codec/src/lib.rs+40−8
@@ -55,7 +55,8 @@ mod tests {         use crate::model::{Footprint, Pad};         let pad = |n: &str, x: f64, mask: Option<f64>, paste: Option<f64>| Pad {             number: n.into(), x_mm: x, y_mm: 0.0, w_mm: 1.0, h_mm: 1.0, drill_mm: 0.0, rotation: 0.0,-            shape: "rect".into(), plated: None, mask_margin_mm: mask, paste_margin_mm: paste, paste_margin_ratio: None };+            shape: "rect".into(), plated: None, mask_margin_mm: mask, paste_margin_mm: paste, paste_margin_ratio: None, drill_slot_mm: None,+        };         let fp = Footprint { name: "EXP".into(), graphics: vec![], polys: vec![],             mask_margin_mm: Some(0.1), paste_margin_mm: None,             pads: vec![pad("1", 0.0, Some(-0.05), Some(-0.05)), pad("2", 2.0, None, None)],@@ -162,6 +163,31 @@ mod tests {         assert!(back.parameters.iter().find(|p| p.name == "VisibleNote").unwrap().visible);     } +    #[test]+    fn slots_and_non_plated_holes_survive_kicad_altium_kicad() {+        // KiCad's GCT USB4105 shell: plated oval drills in oval pads, and two NPTH pegs.+        let sym = "(kicad_symbol_lib (version 20231120) (generator \"t\") (symbol \"U\" (property \"Reference\" \"J\" (at 0 0 0)) (symbol \"U_1_1\" (pin passive line (at -5.08 0 0) (length 2.54) (name \"S\" (effects (font (size 1.27 1.27)))) (number \"SH\" (effects (font (size 1.27 1.27))))))))";+        let fp = "(footprint \"F\" (layer \"F.Cu\")\n (pad \"SH\" thru_hole oval (at -4.32 -3.105) (size 1 2.1) (drill oval 0.6 1.7) (layers \"*.Cu\" \"*.Mask\"))\n (pad \"SH\" thru_hole oval (at 4.32 1.075) (size 1.8 1) (drill oval 1.4 0.6) (layers \"*.Cu\" \"*.Mask\"))\n (pad \"\" np_thru_hole circle (at -2.89 -2.605) (size 0.65 0.65) (drill 0.65) (layers \"*.Cu\" \"*.Mask\")))";+        let part = crate::import_kicad(sym, fp, "USB").unwrap();+        let pads = &part.footprint.pads;+        assert_eq!(pads[0].drill_mm, 0.6, "a slot's round stand-in is its width, never its length");+        assert_eq!(pads[0].drill_slot_mm, Some([0.6, 1.7]));+        assert_eq!(pads[1].drill_slot_mm, Some([1.4, 0.6]), "a slot along the pad's X keeps its axis");+        assert_eq!(pads[2].plated, Some(false));+        let pcb = crate::pcblib::encode_pcblib(&part.footprint).unwrap();+        let back = crate::decode_altium(None, Some(&pcb), "USB").unwrap();+        let bp = &back.footprint.pads;+        let close = |a: [f64; 2], b: [f64; 2]| (a[0] - b[0]).abs() < 1e-4 && (a[1] - b[1]).abs() < 1e-4;+        assert!(close(bp[0].drill_slot_mm.unwrap(), [0.6, 1.7]), "{:?}", bp[0].drill_slot_mm);+        assert!(close(bp[1].drill_slot_mm.unwrap(), [1.4, 0.6]), "{:?}", bp[1].drill_slot_mm);+        assert_eq!(bp[0].plated, Some(true));+        assert_eq!(bp[2].plated, Some(false), "Altium's Plated flag carries the NPTH");+        assert!(bp[2].drill_slot_mm.is_none());+        let k = crate::export_kicad_footprint(&part.footprint);+        assert!(k.contains("(drill oval 0.6 1.7)") && k.contains("(drill oval 1.4 0.6)"), "{k}");+        assert!(k.contains("np_thru_hole"));+    }+     #[test]     fn silk_fp_poly_rides_the_hub_json_and_round_trips_to_kicad() {         // wiki #16: the pin-1 marker is a FILLED F.SilkS polygon in 97 percent@@ -229,7 +255,8 @@ mod tests {         use crate::model::{Footprint, Pad};         use std::io::Read;         let pad = Pad { number: "1".into(), x_mm: 0.0, y_mm: 0.0, w_mm: 1.0, h_mm: 1.0,-                        drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None };+                        drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None, drill_slot_mm: None,+        };         let fp1 = Footprint { name: "WITHMODEL".into(), pads: vec![pad.clone()], graphics: vec![], polys: vec![], mask_margin_mm: None, paste_margin_mm: None, keepouts: Vec::new() };         let fp2 = Footprint { name: "BARE".into(), pads: vec![pad], graphics: vec![], polys: vec![], mask_margin_mm: None, paste_margin_mm: None, keepouts: Vec::new() };         let step = b"ISO-10303-21;\r\nHEADER;\r\nENDSEC;\r\nEND-ISO-10303-21;\r\n".to_vec();@@ -276,7 +303,8 @@ mod tests {         use crate::model::{Pad, Footprint};         let long = "JST_PH_B2B-PH-K_1x02_P2.00mm_Vertical";         let pad = Pad { number: "1".into(), x_mm: 0.0, y_mm: 0.0, w_mm: 1.0, h_mm: 1.0,-                        drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None };+                        drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None, drill_slot_mm: None,+        };         let mk = |name: &str| Footprint { name: name.into(), pads: vec![pad.clone()], graphics: vec![], polys: vec![], mask_margin_mm: None, paste_margin_mm: None, keepouts: Vec::new() };         let bytes = encode_pcblib_many(&[mk(long), mk(&format!("{long}2"))]).expect("encode");         let mut comp = cfb::CompoundFile::open(std::io::Cursor::new(bytes)).unwrap();@@ -395,7 +423,7 @@ mod tests {         b.footprint = Some("FPB".into());         b.pins.push(Pin { number: "3".into(), name: "C".into(), x: -100, y: -300, length: Some(100), rotation: 0, electrical_type: None });         let sch = encode_schlib(&[a, b]).expect("encode schlib");-        let pad = |n: &str, x: f64| Pad { number: n.into(), x_mm: x, y_mm: 0.0, w_mm: 1.0, h_mm: 1.0, drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None };+        let pad = |n: &str, x: f64| Pad { number: n.into(), x_mm: x, y_mm: 0.0, w_mm: 1.0, h_mm: 1.0, drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None, drill_slot_mm: None };         let fpa = Footprint { name: "FPA".into(), pads: vec![pad("1", 0.0)], graphics: vec![], polys: vec![], mask_margin_mm: None, paste_margin_mm: None, keepouts: Vec::new() };         let fpb = Footprint { name: "FPB".into(), pads: vec![pad("1", 0.0), pad("2", 2.0)], graphics: vec![], polys: vec![], mask_margin_mm: None, paste_margin_mm: None, keepouts: Vec::new() };         let pcb = encode_pcblib_many(&[fpa, fpb]).expect("encode pcblib");@@ -427,7 +455,7 @@ mod tests {         let line = |layer: FpLayer, y: f64| FpGraphic::Line { layer, x1: -1.0, y1: y, x2: 1.0, y2: y, width: 0.1 };         let fp = Footprint {             name: "LAYERFP".into(),-            pads: vec![Pad { number: "1".into(), x_mm: 0.0, y_mm: 0.0, w_mm: 1.0, h_mm: 1.0, drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None }],+            pads: vec![Pad { number: "1".into(), x_mm: 0.0, y_mm: 0.0, w_mm: 1.0, h_mm: 1.0, drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None, drill_slot_mm: None }],             polys: vec![],             mask_margin_mm: None,             paste_margin_mm: None,@@ -506,11 +534,15 @@ mod tests {         assert_eq!(npth.plated, Some(false));         let th = &part.footprint.pads[1];         assert_eq!(th.plated, Some(true));-        assert!((th.drill_mm - 1.6).abs() < 1e-9, "slot drill takes the larger axis, got {}", th.drill_mm);+        // A slot keeps both axes; its round stand-in is the narrow side, so a reader+        // without slot support never drills outside the slot.+        assert!((th.drill_mm - 1.0).abs() < 1e-9, "slot's round stand-in is its width, got {}", th.drill_mm);+        assert_eq!(th.drill_slot_mm, Some([1.0, 1.6]));          let out = export_kicad_footprint(&part.footprint);         assert!(out.contains("np_thru_hole"), "export keeps np_thru_hole:\n{out}");         assert!(out.contains("(drill 3.2)"), "export keeps the NPTH drill:\n{out}");+        assert!(out.contains("(drill oval 1 1.6)"), "export keeps the slot:\n{out}");     }      #[test]@@ -518,8 +550,8 @@ mod tests {         let fp = Footprint {             name: "REFFP".into(),             pads: vec![-                Pad { number: "1".into(), x_mm: -0.762, y_mm: 0.0, w_mm: 1.016, h_mm: 1.27, drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None },-                Pad { number: "2".into(), x_mm: 0.762, y_mm: 0.0, w_mm: 1.016, h_mm: 1.27, drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None },+                Pad { number: "1".into(), x_mm: -0.762, y_mm: 0.0, w_mm: 1.016, h_mm: 1.27, drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None, drill_slot_mm: None },+                Pad { number: "2".into(), x_mm: 0.762, y_mm: 0.0, w_mm: 1.016, h_mm: 1.27, drill_mm: 0.0, rotation: 0.0, shape: "rect".into(), plated: None, mask_margin_mm: None, paste_margin_mm: None, paste_margin_ratio: None, drill_slot_mm: None },             ],             graphics: vec![],             polys: vec![],
crates/altium-codec/src/model.rs+7−4
@@ -402,10 +402,8 @@ pub struct Pad {     pub shape: String,     /// Through-hole plating. `None`/`Some(true)` → plated (normal TH pad);     /// `Some(false)` → NPTH (KiCad `np_thru_hole`, e.g. a mounting hole).-    /// Only meaningful when `drill_mm > 0`. NOTE: the Altium binary encoder-    /// currently emits NPTH as a plated TH pad (the plated flag byte in the-    /// pad record is not yet calibrated) — the hole survives, the plating-    /// distinction doesn't. KiCad export round-trips it faithfully.+    /// Only meaningful when `drill_mm > 0`. Every lane carries it: KiCad+    /// `np_thru_hole`, the Altium pad's Plated flag, EAGLE `<hole>`.     #[serde(default, skip_serializing_if = "Option::is_none")]     pub plated: Option<bool>,     /// Per-pad solder-mask margin in mm (KiCad `solder_mask_margin`), signed:@@ -420,6 +418,11 @@ pub struct Pad {     /// `solder_paste_margin_ratio`, -1.0 to 1.0).     #[serde(default, skip_serializing_if = "Option::is_none")]     pub paste_margin_ratio: Option<f64>,+    /// A slotted (oval) drill, KiCad `(drill oval W H)`: [W, H] in mm in the pad's+    /// own frame, before its rotation. `drill_mm` is then the narrow side, so a+    /// reader that predates this field drills a hole that stays inside the slot.+    #[serde(default, skip_serializing_if = "Option::is_none")]+    pub drill_slot_mm: Option<[f64; 2]>, }  fn default_shape() -> String {
crates/altium-codec/src/pcblib.rs+40−2
@@ -495,7 +495,10 @@ fn encode_pad_record(pad: &Pad, fp: &Footprint, pad_tpl: &[u8]) -> Vec<u8> {     let y_units = (-pad.y_mm * MM_TO_UNIT).round() as i32; // Y-down → Altium Y-up     let xs = (pad.w_mm * MM_TO_UNIT).round() as u32;     let ys = (pad.h_mm * MM_TO_UNIT).round() as u32;-    let hole = (pad.drill_mm * MM_TO_UNIT).round() as u32;+    // A slot's hole size is its width; its length goes in sub-block 6.+    let slot = pad.drill_slot_mm.filter(|s| pad.drill_mm > 0.0 && s[0] > 0.0 && s[1] > 0.0 && (s[0] - s[1]).abs() > 1e-9);+    let hole_mm = slot.map(|[w, h]| w.min(h)).unwrap_or(pad.drill_mm);+    let hole = (hole_mm * MM_TO_UNIT).round() as u32;     let shape = shape_byte(&pad.shape);     // Altium layer ids: 1 = Top, 32 = Bottom, 33 = Top Overlay, 74 = Multi-Layer. A drilled     // pad must sit on Multi-Layer (74) to be a plated through-hole; 0x21 (33) put the ToF@@ -522,6 +525,12 @@ fn encode_pad_record(pad: &Pad, fp: &Footprint, pad_tpl: &[u8]) -> Vec<u8> {     pd[49] = shape;     pd[50] = shape;     pd[51] = shape;+    // Byte 60 is Plated. A KiCad np_thru_hole (a peg, a mounting hole) is a+    // Multi-Layer pad with Plated = False, as Altium saves one; it was written+    // plated, so the NC drill file plated every peg.+    if pd.len() > 60 {+        pd[60] = if hole > 0 && pad.plated == Some(false) { 0 } else { 1 };+    }     if pd.len() >= 60 {         pd[52..60].copy_from_slice(&pad.rotation.to_le_bytes());     }@@ -541,13 +550,15 @@ fn encode_pad_record(pad: &Pad, fp: &Footprint, pad_tpl: &[u8]) -> Vec<u8> {         }     } +    let size_and_shape = slot.map(|[w, h]| slot_size_and_shape(xs, ys, shape, w.max(h), if h > w { 90.0 } else { 0.0 }))+        .unwrap_or_default();     let blocks: [&[u8]; 6] = [         &designator,         &[0x00],         &[0x04, 0x7c, 0x26, 0x7c, 0x30],         &[0x00],         &pd,-        &[],+        &size_and_shape,     ];     let mut rec = vec![0x02u8];     for b in blocks {@@ -557,6 +568,33 @@ fn encode_pad_record(pad: &Pad, fp: &Footprint, pad_tpl: &[u8]) -> Vec<u8> {     rec } +/// Pad sub-block 6 ("size and shape"), the 596-byte form, for a slotted hole: 29+/// inner-layer sizes and shapes (the pad's own), a skipped byte, hole shape 2+/// (slot) at 262, slot length at 263, slot rotation relative to the pad at 267+/// (0 along the pad's X, 90 along its Y), 32 zero hole offsets, a skipped byte,+/// 32 alternate shapes and 32 corner radii. Laid out after KiCad's Altium+/// importer and checked against slotted USB connector pads Altium saved+/// (Celestial library, TE 2129691-1 and Amphenol 87583): their pads give the+/// slot width as the hole size and the slot length here, rotation pad-relative.+fn slot_size_and_shape(xs: u32, ys: u32, shape: u8, length_mm: f64, rotation: f64) -> Vec<u8> {+    let mut b = Vec::with_capacity(596);+    for _ in 0..29 { b.extend_from_slice(&xs.to_le_bytes()); }+    for _ in 0..29 { b.extend_from_slice(&ys.to_le_bytes()); }+    // The per-layer list holds the basic shapes (1 round, 2 rect, 3 octagonal);+    // a rounded rectangle is rect there and 9 in the alternate-shape list.+    b.extend(std::iter::repeat(if shape == 9 { 2 } else { shape }).take(29));+    b.push(0);+    b.push(2);+    b.extend_from_slice(&((length_mm * MM_TO_UNIT).round() as u32).to_le_bytes());+    b.extend_from_slice(&rotation.to_le_bytes());+    b.extend(std::iter::repeat(0u8).take(32 * 4 * 2));+    b.push(0);+    b.extend(std::iter::repeat(shape).take(32));+    b.extend(std::iter::repeat(if shape == 9 { 50u8 } else { 0 }).take(32));+    debug_assert_eq!(b.len(), 596);+    b+}+ fn shape_byte(shape: &str) -> u8 {     match shape {         "circle" | "oval" => 1,
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "adom-lbr",-  "version": "2.47.13",+  "version": "2.47.14",   "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.13",+  "version": "2.47.14",   "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+64−16
@@ -1235,6 +1235,9 @@ struct ModPad {     dy: f64,     angle: f64,     drill: Option<f64>,+    /// A slotted drill, KiCad `(drill oval W H)` in the pad's own frame; `drill` is then+    /// the narrow side.+    slot: Option<(f64, f64)>,     /// EAGLE pad shape mapped from the KiCad shape token: "round" | "square" |     /// "long" | "octagon".     shape: String,@@ -1301,7 +1304,7 @@ fn parse_mod_pads(km: &str) -> Vec<ModPad> {     let name_re = regex_lite::Regex::new(r#"^\(pad\s+(?:"([^"]*)"|(\S+))\s+(\S+)\s+(\S+)"#).unwrap();     let at_re = regex_lite::Regex::new(r#"\(at\s+(-?[\d.]+)\s+(-?[\d.]+)(?:\s+(-?[\d.]+))?\s*\)"#).unwrap();     let size_re = regex_lite::Regex::new(r#"\(size\s+(-?[\d.]+)\s+(-?[\d.]+)\s*\)"#).unwrap();-    let drill_re = regex_lite::Regex::new(r#"\(drill\s+(-?[\d.]+)"#).unwrap();+    let drill_re = regex_lite::Regex::new(r#"\(drill\s+(oval\s+)?(-?[\d.]+)(?:\s+(-?[\d.]+))?"#).unwrap();     // KiCad states the corner radius as a RATIO of the smaller side; EAGLE states it as a     // percent of the same side, and a ratio of 0.5 is a fully rounded end. So N = r * 200.     let rr_re = regex_lite::Regex::new(r#"\(roundrect_rratio\s+(-?[\d.]+)"#).unwrap();@@ -1339,7 +1342,18 @@ fn parse_mod_pads(km: &str) -> Vec<ModPad> {         let layers = block.split("(layers").nth(1).map(|t| t.split(')').next().unwrap_or("")).unwrap_or("");         let paste = !smd || layers.contains("Paste");         let mask = !smd || layers.contains("Mask");-        let drill = drill_re.captures(block).and_then(|c| c[1].parse().ok());+        // (drill d) or (drill oval w [h]): a slot's round stand-in is its narrow side.+        let (drill, slot) = match drill_re.captures(block) {+            Some(c) => {+                let w: Option<f64> = c[2].parse().ok();+                let h: Option<f64> = c.get(3).and_then(|m| m.as_str().parse().ok());+                match (c.get(1).is_some(), w, h) {+                    (true, Some(w), Some(h)) if (w - h).abs() > 1e-9 => (Some(w.min(h)), Some((w, h))),+                    _ => (w, None),+                }+            }+            None => (None, None),+        };         // KiCad pad shape → EAGLE pad shape.         let kicad_shape = nc.get(4).map(|m| m.as_str()).unwrap_or("").to_string();         let shape = match kicad_shape.as_str() {@@ -1349,7 +1363,7 @@ fn parse_mod_pads(km: &str) -> Vec<ModPad> {             "roundrect" | "custom" => "round",             _ => "round",         }.to_string();-        pads.push(ModPad { name, smd, x, y, dx, dy, angle, drill, shape, kicad_shape, roundness, paste, mask });+        pads.push(ModPad { name, smd, x, y, dx, dy, angle, drill, slot, shape, kicad_shape, roundness, paste, mask });     }     pads }@@ -1436,24 +1450,43 @@ fn holes_eagle_xml(km: &str) -> String {         if h.long - h.short > 1e-6 {             eprintln!("WARN: oval non-plated hole {:.2} x {:.2} mm at ({:.3}, {:.3}): EAGLE holes are round, so it is drilled {:.2} mm and the slot is drawn on layer 46 Milling",                 h.short, h.long, h.x, h.y, h.short);-            let (s, c) = h.axis.to_radians().sin_cos();-            let (half, r) = ((h.long - h.short) / 2.0, h.short / 2.0);-            // The two end-cap centres, and the outline offset either side of the axis.-            let (c1, c2) = ((h.x - c * half, h.y - s * half), (h.x + c * half, h.y + s * half));-            let (nx, ny) = (-s * r, c * r);-            for ((x1, y1), (x2, y2), curve) in [-                ((c1.0 + nx, c1.1 + ny), (c2.0 + nx, c2.1 + ny), ""),-                ((c2.0 + nx, c2.1 + ny), (c2.0 - nx, c2.1 - ny), " curve=\"-180\""),-                ((c2.0 - nx, c2.1 - ny), (c1.0 - nx, c1.1 - ny), ""),-                ((c1.0 - nx, c1.1 - ny), (c1.0 + nx, c1.1 + ny), " curve=\"-180\""),-            ] {-                xml.push_str(&format!("  <wire x1=\"{:.4}\" y1=\"{:.4}\" x2=\"{:.4}\" y2=\"{:.4}\" width=\"0\" layer=\"46\"{}/>\n", x1, y1, x2, y2, curve));-            }+            xml.push_str(&slot_milling_xml(h.x, h.y, h.long, h.short, h.axis));         }     }     xml } +/// The outline of a slot on layer 46 Milling, where EAGLE and Fusion CAM take+/// non-round cutouts from: two straight sides and two half-circle ends. EAGLE+/// coordinates (Y-up), axis in EAGLE degrees.+fn slot_milling_xml(x: f64, y: f64, long: f64, short: f64, axis: f64) -> String {+    let mut xml = String::new();+    let (s, c) = axis.to_radians().sin_cos();+    let (half, r) = ((long - short) / 2.0, short / 2.0);+    // The two end-cap centres, and the outline offset either side of the axis.+    let (c1, c2) = ((x - c * half, y - s * half), (x + c * half, y + s * half));+    let (nx, ny) = (-s * r, c * r);+    for ((x1, y1), (x2, y2), curve) in [+        ((c1.0 + nx, c1.1 + ny), (c2.0 + nx, c2.1 + ny), ""),+        ((c2.0 + nx, c2.1 + ny), (c2.0 - nx, c2.1 - ny), " curve=\"-180\""),+        ((c2.0 - nx, c2.1 - ny), (c1.0 - nx, c1.1 - ny), ""),+        ((c1.0 - nx, c1.1 - ny), (c1.0 + nx, c1.1 + ny), " curve=\"-180\""),+    ] {+        xml.push_str(&format!("  <wire x1=\"{:.4}\" y1=\"{:.4}\" x2=\"{:.4}\" y2=\"{:.4}\" width=\"0\" layer=\"46\"{}/>\n", x1, y1, x2, y2, curve));+    }+    xml+}++/// A plated pad's slotted drill for EAGLE, whose pad drill is round only: the pad is+/// drilled at the slot's width (the `drill` already set), the full slot is drawn on+/// Milling, and the loss is named.+fn pad_slot_xml(p: &ModPad, name: &str) -> String {+    let Some((w, h)) = p.slot else { return String::new() };+    let (long, short) = (w.max(h), w.min(h));+    eprintln!("WARN: [slot-drill] pad {name}: plated slot {short:.2} x {long:.2} mm; an EAGLE pad drill is round, so it is drilled {short:.2} mm and the slot is drawn on layer 46 Milling. Check that the fab plates the milled slot.");+    slot_milling_xml(p.x, -p.y, long, short, p.angle + if h > w { 90.0 } else { 0.0 })+}+ /// Map a KiCad pad rotation (degrees) to an EAGLE `rot=` attribute, matching /// Fusion 360's own library export convention: the KiCad angle maps directly /// (KiCad 90 → `R90`), so a non-square pad on a QFP/SOIC top/bottom side is@@ -1635,6 +1668,7 @@ fn emit_variant_package(xml: &mut String, km: &str, name: &str, description: &st             xml.push_str(&format!(                 "  <pad name=\"{}\" x=\"{:.4}\" y=\"{:.4}\" drill=\"{:.4}\" diameter=\"{:.4}\" shape=\"{}\"{}/>\n",                 esc_xml(&out_names[i]), p.x, -p.y, drill, diameter, tht_shape, smd_rotation(p.angle + extra_rot)));+            xml.push_str(&pad_slot_xml(p, &out_names[i]));         }     }     xml.push_str(&holes_eagle_xml(km));@@ -2599,6 +2633,7 @@ pub(crate) fn generate_lbr_gates(sym: &ParsedSymbol, fp_content: Option<&str>, s                 xml.push_str(&format!(                     "  <pad name=\"{}\" x=\"{:.4}\" y=\"{:.4}\" drill=\"{:.4}\" diameter=\"{:.4}\" shape=\"{}\"{}/>\n",                     esc_xml(&out_names[i]), p.x, -p.y, drill, diameter, tht_shape, smd_rotation(p.angle + extra_rot)));+                xml.push_str(&pad_slot_xml(p, &out_names[i]));             }         }         xml.push_str(&holes_eagle_xml(km));@@ -5699,6 +5734,19 @@ mod npth_tests {         assert!(lint_lbr(&xml).errors.is_empty(), "{:?}", lint_lbr(&xml).errors);     } +    #[test]+    fn a_plated_slot_is_drilled_at_its_width_and_milled_in_eagle() {+        let km = r#"(footprint "T"+            (pad "SH" thru_hole oval (at 0 0) (size 1 2.1) (drill oval 0.6 1.7) (layers "*.Cu" "*.Mask")))"#;+        let pads = parse_mod_pads(km);+        assert_eq!(pads[0].drill, Some(0.6), "the round drill is the slot's width, not its length");+        assert_eq!(pads[0].slot, Some((0.6, 1.7)));+        let xml = pad_slot_xml(&pads[0], "SH");+        assert_eq!(xml.matches(r#"layer="46""#).count(), 4, "two sides and two ends on Milling");+        // the slot runs along the pad's Y: 1.7 long, so its straight sides span y = +-0.55+        assert!(xml.contains(r#"y1="-0.5500""#) && xml.contains(r#"y2="0.5500""#), "{xml}");+    }+     #[test]     fn a_drill_offset_turns_with_the_pad() {         let km = r#"(footprint "T"