by barrett-land
Install ADOM'S OWN machine pin/contact library into the user's EDA — KiCad, Altium Designer, OR Fusion 360. Fetches the six machine components from the wiki, converts them with adom-lbr into 'Adom Machine Symbols' + 'Adom Machine Footprints' (one combined .lbr for Fusion), and pushes them into the chosen EDA over adom-desktop. Asks which EDA first. Supersedes adom-altium-library-importer (its Altium path is folded in). Not a general component-adder.
← Commit history
Publish 1.0.1
5 files changed
+112−57
page.json+2−2@@ -1,6 +1,6 @@ { "slug": "adom-library-importer",- "version": "1.0.0",+ "version": "1.0.1", "type": "skill", "description": "Install ADOM'S OWN machine pin/contact library into the user's EDA — KiCad, Altium Designer, OR Fusion 360. Fetches the six machine components from the wiki, converts them with adom-lbr into 'Adom Machine Symbols' + 'Adom Machine Footprints' (one combined .lbr for Fusion), and pushes them into the chosen EDA over adom-desktop. Asks which EDA first. Supersedes adom-altium-library-importer (its Altium path is folded in). Not a general component-adder.", "tags": [@@ -66,4 +66,4 @@ "name": "barrett-land", "email": "[email protected]" }-}+}
skills/adom-library-importer/SKILL.md+9−10@@ -27,12 +27,11 @@ registers the right files into the user's **KiCad**, **Altium**, or **Fusion 360 | Deliverable | KiCad | Altium | Fusion 360 | |---|---|---|---| | **Adom Machine Symbols** | `.kicad_sym` (6 symbols) | native `.SchLib` (6 symbols) | folded into the one `.lbr` |-| **Adom Machine Footprints** | `.pretty/` (6 `.kicad_mod`) | `.PcbLib` (built at install, 6 fp + 3D) | folded into the one `.lbr` |+| **Adom Machine Footprints** | `.pretty/` (6 `.kicad_mod`) | `.PcbLib` (6 fp + 3D bodies) | folded into the one `.lbr` | -> The library page hosts the KiCad libs, the Altium `.SchLib`, and the Fusion `.lbr`-> pre-built. The Altium `.PcbLib` is assembled **at install** from the component deps-> (`adom-lbr` has no offline multi-part `.PcbLib` merge). Fusion keeps symbols + footprints-> in **one** `Adom Machine Library.lbr`.+> All three EDAs' libraries are **pre-built and hosted** on the library page, including the+> Altium `.PcbLib` (6 footprints + STEP 3D bodies, validated on Altium Designer 26.7). Install+> is download + register. Fusion keeps symbols + footprints in **one** `Adom Machine Library.lbr`. ## Step 0 — ASK which EDA (do this first) @@ -62,11 +61,11 @@ python ~/.claude/skills/adom-library-importer/import_library.py --eda kicad `kicad_lint_library` both, then `kicad_install_library` (`libraryType:"symbol"` / `libraryType:"footprint"`) into the newest KiCad's sym-/fp-lib-table. - **Altium** — needs the **`altium` bridge** (auto-installed if missing) and Altium open.- Symbols: send + register the hosted native `.SchLib`. Footprints: append each component's- footprint (+ STEP 3D body) into one `.PcbLib` via `altium_build_footprint` (the folded-in- old-skill logic), reading geometry from the installed component deps, then- `altium_install_library`. **Keep symbol + footprint libs registered together** — the- symbol→footprint link resolves by footprint name.+ Send + register the hosted native `.SchLib` and the hosted pre-built `.PcbLib`+ (`altium_install_library`). **Keep symbol + footprint libs registered together** — the+ symbol→footprint link resolves by footprint name. (If the hosted `.PcbLib` is ever missing,+ the skill falls back to building it from the component deps — ONE footprint at a time,+ clearing Altium's 'another instance busy' modal between builds; see `altium_footprints.py`.) - **Fusion 360** — send the hosted `Adom Machine Library.lbr` and `fusion_open_lbr` it into the Electronics Library editor. **2D only** — real 3D bodies bind per Fusion account (`wip_urn`); run the per-pin `fusion_make_3d_package` rebind from the **`adom-machine-pin-fusion-library`**
skills/adom-library-importer/altium_footprints.py+48−25@@ -2,13 +2,23 @@ """Assemble the merged 'Adom Machine Footprints.PcbLib' on the desktop. adom-lbr has no offline multi-part .PcbLib merge (it does for .SchLib via-add-to-schlib), so the ONE Altium step that needs Altium open is building the-footprint library: for each part we parse its .kicad_mod pads, push its .step,-and drive the altium bridge `altium_build_footprint` in APPEND mode so all six-land pattern + 3D body pairs accumulate into a single .PcbLib. Ported from the-old adom-altium-library-importer convert.py."""-import os, re-from bridge import ad, send_file+add-to-schlib), so the footprint library is built by driving Altium: for each+part we parse its .kicad_mod pads, push its .step, and drive the altium bridge+`altium_build_footprint` in APPEND mode so all six land-pattern + 3D-body pairs+accumulate into one .PcbLib.++RELIABILITY (learned the hard way against Altium Designer 26.7):+- Fire ONE build at a time. Firing several back-to-back makes Altium pop a modal+ 'another instance ... is busy' Information dialog that blocks EVERY later build.+- Clear that dialog before/after each build (bridge.dismiss_altium_busy_dialogs).+- The relay caps a bridge response at ~60s; a build can exceed that and return+ 'Request timed out' while the DelphiScript still SAVES. So verify by polling the+ .PcbLib file size (it grows per footprint), not by the call's return value.++Used at REGENERATION time (the library page ships the pre-built .PcbLib). Ported+and hardened from the old adom-altium-library-importer convert.py."""+import os, re, time+from bridge import ad, send_file, desktop_list_files, dismiss_altium_busy_dialogs MM_PER_MIL = 0.0254 def _mm2mil(mm): return int(round(float(mm) / MM_PER_MIL))@@ -38,26 +48,39 @@ def _parse_pads(kicad_mod_path): return pads +def _build_one(part, pcblib_win, dest_folder):+ pads = _parse_pads(part["kicad_mod"])+ step_desk = send_file(part["step"], dest_folder) if os.path.exists(part["step"]) else None+ payload = {"footprint": part["name"], "pcblib": pcblib_win,+ "step": (step_desk or ""), "padcount": str(len(pads)), "timeout": 150}+ for i, pad in enumerate(pads):+ payload["pad%d" % i] = ",".join(str(x) for x in pad)+ return ad("altium_build_footprint", payload) # may 'time out' but still persist++ def build_pcblib(parts, pcblib_win, dest_folder):- """parts: [{name, kicad_mod, step}]. Appends each footprint (+STEP 3D body)- into pcblib_win (a Windows path). Returns list of (name, ok, err)."""+ """Append each footprint (+STEP 3D body) into pcblib_win, ONE AT A TIME, with+ dialog-dismissal and file-size verification between builds. Returns list of+ (name, ok, err)."""+ folder = pcblib_win.rsplit("\\", 1)[0]+ pcblib_name = pcblib_win.rsplit("\\", 1)[1] results = [] for p in parts:- pads = _parse_pads(p["kicad_mod"])- step_desk = send_file(p["step"], dest_folder) if os.path.exists(p["step"]) else None- payload = {- "footprint": p["name"],- "pcblib": pcblib_win,- "step": (step_desk or ""),- "padcount": str(len(pads)),- "timeout": 150,- }- for i, pad in enumerate(pads):- payload["pad%d" % i] = ",".join(str(x) for x in pad)- r = ad("altium_build_footprint", payload)- ok = bool(r.get("ok"))- results.append((p["name"], ok, None if ok else (r.get("error") or r)))+ dismiss_altium_busy_dialogs()+ prev = desktop_list_files(folder).get(pcblib_name, -1) # -1 => not yet created+ r = _build_one(p, pcblib_win, dest_folder)+ # verify the footprint persisted: the .PcbLib is created or grows+ ok = False+ for _ in range(16): # up to ~160s+ dismiss_altium_busy_dialogs()+ cur = desktop_list_files(folder).get(pcblib_name, -1)+ if cur > prev:+ ok = True+ break+ time.sleep(10)+ err = None if ok else (r.get("error") or "footprint did not persist")+ results.append((p["name"], ok, err)) print(f" {'OK ' if ok else 'FAIL'} footprint {p['name']} "- f"(pads={len(pads)}, 3d={r.get('step_body')})"- + ("" if ok else f" ERR={r.get('error')}"))+ f"(pads={len(_parse_pads(p['kicad_mod']))}, 3d={r.get('step_body')})"+ + ("" if ok else f" ERR={err}")) return results
skills/adom-library-importer/bridge.py+28−2@@ -1,7 +1,7 @@ #!/usr/bin/env python3 """adom-desktop helpers shared by the importer: envelope-unwrapping call, desktop-reachability, and one-time altium-bridge install. Adapted from the old-adom-altium-library-importer install.py."""+reachability, one-time altium-bridge install, and Altium busy-dialog handling.+Adapted from the old adom-altium-library-importer install.py.""" import json, subprocess, time ALTIUM_BRIDGE_MANIFEST = ("https://wiki.adom.inc/download/barrett-land/"@@ -40,6 +40,32 @@ def send_file(local_path, dest_folder): return dest.replace("/", "\\") if dest else None +def desktop_list_files(folder_win):+ """{name: size} for a Windows folder (via the file layer, not the shell)."""+ r = ad("desktop_list_files", {"path": folder_win})+ return {f["name"]: f["size"] for f in ((r.get("data") or r).get("files") or [])}+++def dismiss_altium_busy_dialogs(rounds=6):+ """Clear Altium's 'another instance ... is busy' Information modal.++ Firing overlapping altium_build_footprint calls makes Altium pop a modal+ 'Information' dialog that then BLOCKS every subsequent build (each call just+ times out with nothing saved). Building ONE footprint at a time and clearing+ this dialog between builds is what makes the Altium path reliable.+ """+ for _ in range(rounds):+ r = ad("desktop_list_windows")+ ws = r.get("windows") or (r.get("data") or {}).get("windows") or []+ hwnd = next((w.get("hwnd") or w.get("handle") for w in ws+ if (w.get("title") or "").strip().lower().startswith("information")), None)+ if not hwnd:+ return+ ad("desktop_bring_to_front", {"hwnd": hwnd})+ ad("desktop_press_key", {"key": "Enter"})+ time.sleep(1)++ # --------------------------------------------------------------- Altium bridge def altium_ready(): r = ad("altium_ping")
skills/adom-library-importer/import_library.py+25−18@@ -98,8 +98,9 @@ def install_kicad(lib_dir, dest_folder): def install_altium(lib_dir, dest_folder): if not ensure_altium_bridge(): sys.exit("altium bridge / Altium not ready.")+ altium = os.path.join(lib_dir, "libs", "altium") # Symbols: hosted native merged .SchLib (built offline on the library page).- schlib = os.path.join(lib_dir, "libs", "altium", lib_build.SYM_LIB + ".SchLib")+ schlib = os.path.join(altium, lib_build.SYM_LIB + ".SchLib") sch_desk = send_file(schlib, dest_folder) if not sch_desk: sys.exit("failed to send the SchLib to the desktop")@@ -108,25 +109,31 @@ def install_altium(lib_dir, dest_folder): print(f" {'OK ' if ok_sym else 'FAIL'} symbol lib -> {sch_desk}" + ("" if ok_sym else f" ({r.get('error')})")) - # Footprints: assemble Adom Machine Footprints.PcbLib on the desktop from the- # component dependencies (kicad_mod + STEP), append mode.- import altium_footprints- comp_dirs = _component_dirs()- if len(comp_dirs) < len(COMPONENTS):- print(f" WARN only {len(comp_dirs)}/{len(COMPONENTS)} component deps found under "- f"adom_modules/adom — run `adom-wiki pkg install {LIBRARY_REF}` first.")- parts = [{"name": n, "kicad_mod": os.path.join(d, n + ".kicad_mod"),- "step": os.path.join(d, n + ".step")}- for n, d in comp_dirs.items()]- pcblib_desk = f"{sch_desk.rsplit(chr(92), 1)[0]}\\{lib_build.FP_LIB}.PcbLib"- print(f"building {lib_build.FP_LIB}.PcbLib on the desktop (append mode)…")- fp_results = altium_footprints.build_pcblib(parts, pcblib_desk, dest_folder)- ok_fp = bool(parts) and all(ok for _, ok, _ in fp_results)- if ok_fp:- r = ad("altium_install_library", {"path": pcblib_desk})+ # Footprints: the library page ships a PRE-BUILT Adom Machine Footprints.PcbLib+ # (6 footprints + 3D bodies, validated on Altium 26.7). Just send + register it.+ pcblib = os.path.join(altium, lib_build.FP_LIB + ".PcbLib")+ if os.path.exists(pcblib):+ fp_desk = send_file(pcblib, dest_folder)+ r = ad("altium_install_library", {"path": fp_desk}) if fp_desk else {"ok": False} ok_fp = bool(r.get("ok"))- print(f" {'OK ' if ok_fp else 'FAIL'} footprint lib -> {pcblib_desk}"+ print(f" {'OK ' if ok_fp else 'FAIL'} footprint lib -> {fp_desk}" + ("" if ok_fp else f" ({r.get('error')})"))+ else:+ # Fallback (regeneration / missing asset): build the .PcbLib on the desktop+ # from the component deps, ONE footprint at a time (see altium_footprints).+ import altium_footprints+ comp_dirs = _component_dirs()+ parts = [{"name": n, "kicad_mod": os.path.join(d, n + ".kicad_mod"),+ "step": os.path.join(d, n + ".step")} for n, d in comp_dirs.items()]+ pcblib_desk = f"{sch_desk.rsplit(chr(92), 1)[0]}\\{lib_build.FP_LIB}.PcbLib"+ print(f"no hosted PcbLib — building {lib_build.FP_LIB}.PcbLib on the desktop…")+ fp_results = altium_footprints.build_pcblib(parts, pcblib_desk, dest_folder)+ ok_fp = bool(parts) and all(ok for _, ok, _ in fp_results)+ if ok_fp:+ r = ad("altium_install_library", {"path": pcblib_desk})+ ok_fp = bool(r.get("ok"))+ print(f" {'OK ' if ok_fp else 'FAIL'} footprint lib -> {pcblib_desk}"+ + ("" if ok_fp else f" ({r.get('error')})")) # keep symbol + footprint libs registered together (link resolves by footprint name). return ok_sym and ok_fp