app
Adom Library
Public Made by Adomby adom
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.
← Commit history
2.27.0: keep >NAME and >VALUE out of the pin lanes
7 files changed
+47−10
Cargo.lock+1−1@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "adom-lbr"-version = "2.26.0"+version = "2.27.0" dependencies = [ "altium-codec", "anyhow",
Cargo.toml+1−1@@ -1,6 +1,6 @@ [package] name = "adom-lbr"-version = "2.26.0"+version = "2.27.0" 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.26.0+2.27.0
bin/adom-lbr⋯ 1 unchanged line ⋯
package.json+1−1@@ -1,6 +1,6 @@ { "slug": "adom-lbr",- "version": "2.26.0",+ "version": "2.27.0", "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.26.0",+ "version": "2.27.0", "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": {},@@ -88,4 +88,4 @@ "label": "Browse parts" } ]-}+}
src/main.rs+41−4@@ -1711,10 +1711,47 @@ fn emit_symbol_block(xml: &mut String, sym: &ParsedSymbol, symbol_art: Option<&S } } - let name_y = sym.body.as_ref().map(|b| b.top + 2.54).unwrap_or(10.0);- let value_y = sym.body.as_ref().map(|b| b.bottom - 2.54).unwrap_or(-10.0);- xml.push_str(&format!(" <text x=\"0\" y=\"{}\" size=\"1.27\" layer=\"95\" align=\"bottom-center\">>NAME</text>\n", name_y));- xml.push_str(&format!(" <text x=\"0\" y=\"{}\" size=\"1.27\" layer=\"96\" align=\"top-center\">>VALUE</text>\n", value_y));+ // >NAME and >VALUE GO WHERE A WIRE CANNOT. They used to sit 2.54 mm above the body top+ // and below the body bottom, which is correct for a two-column symbol and wrong for a+ // four-sided one: that is exactly the lane the top and bottom pin stubs occupy, so every+ // net a user draws to those pins runs straight through the label (John, on the CH340G-SQ+ // frame). When the symbol has pins on the top or bottom edge, both labels move INSIDE+ // the body, into the interior rectangle left free by the pin names.+ let has_vertical_pins = sym.pins.iter().any(|p| p.angle == 90 || p.angle == 270);+ let pin_name_w = |p: &KicadPin| dedup_pin_names(std::slice::from_ref(p))[0].chars().count() as f64 * 0.6 * 1.778;+ match (&sym.body, has_vertical_pins) {+ (Some(b), true) => {+ // Interior free rect: pull each side in by that side's longest pin name plus+ // KiCad's 1.016 mm name offset. This is the same rectangle adom-symbol computes+ // to fit the chip icon.+ let inset = |sel: &dyn Fn(&KicadPin) -> bool| -> f64 {+ sym.pins.iter().filter(|p| sel(p)).map(pin_name_w).fold(0.0, f64::max) + 1.016+ };+ let l = b.left + inset(&|p: &KicadPin| p.angle == 0);+ let r = b.right - inset(&|p: &KicadPin| p.angle == 180);+ let t = b.top - inset(&|p: &KicadPin| p.angle == 270);+ let bo = b.bottom + inset(&|p: &KicadPin| p.angle == 90);+ let cx = (l + r) / 2.0;+ if t - bo >= 2.0 * 1.27 && r - l >= 4.0 {+ xml.push_str(&format!(" <text x=\"{:.4}\" y=\"{:.4}\" size=\"1.27\" layer=\"95\" align=\"top-center\">>NAME</text>\n", cx, t));+ xml.push_str(&format!(" <text x=\"{:.4}\" y=\"{:.4}\" size=\"1.27\" layer=\"96\" align=\"bottom-center\">>VALUE</text>\n", cx, bo));+ } else {+ // The interior is too small for 1.27 mm text (a tiny square symbol). Put the+ // labels in the corners BEYOND the pin extents, where a wire still cannot go.+ let far = sym.pins.iter().map(|p| p.x.abs() + p.length).fold(0.0, f64::max) + 1.27;+ xml.push_str(&format!(" <text x=\"{:.4}\" y=\"{:.4}\" size=\"1.27\" layer=\"95\" align=\"bottom-left\">>NAME</text>\n", far, b.top));+ xml.push_str(&format!(" <text x=\"{:.4}\" y=\"{:.4}\" size=\"1.27\" layer=\"96\" align=\"top-left\">>VALUE</text>\n", far, b.bottom));+ }+ }+ (body, _) => {+ // No pins on the top or bottom edge: above and below the body is free space, and+ // it is where an engineer expects to read the designator.+ let name_y = body.as_ref().map(|b| b.top + 2.54).unwrap_or(10.0);+ let value_y = body.as_ref().map(|b| b.bottom - 2.54).unwrap_or(-10.0);+ xml.push_str(&format!(" <text x=\"0\" y=\"{}\" size=\"1.27\" layer=\"95\" align=\"bottom-center\">>NAME</text>\n", name_y));+ xml.push_str(&format!(" <text x=\"0\" y=\"{}\" size=\"1.27\" layer=\"96\" align=\"top-center\">>VALUE</text>\n", value_y));+ }+ } let deduped_names = dedup_pin_names(&sym.pins); // A GLYPH SYMBOL HIDES ITS PIN NAMES. EAGLE draws a pin's name at its INNER end, which