Fix: handle missing library_link attribute on Footprint objects in KiCad 9 (#157)

KiCad 9's IPC API returns Footprint objects where fp.definition lacks
the library_link attribute, causing all component queries to fail with
"'Footprint' object has no attribute 'library_link'" warnings and
returning 0 components. This adds a hasattr check with fallback to
fp.definition.id.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gavin Colonese
2026-05-18 13:39:22 -04:00
committed by GitHub
parent 8d79f7b801
commit d62ff4a7c8
2 changed files with 90 additions and 1 deletions

View File

@@ -418,7 +418,15 @@ class IPCBoardAPI(BoardAPI):
fp.reference_field.text.value if fp.reference_field else ""
),
"value": fp.value_field.text.value if fp.value_field else "",
"footprint": str(fp.definition.library_link) if fp.definition else "",
"footprint": (
str(fp.definition.library_link)
if fp.definition and hasattr(fp.definition, "library_link")
else (
str(fp.definition.id)
if fp.definition and hasattr(fp.definition, "id")
else ""
)
),
"position": {
"x": to_mm(pos.x) if pos else 0,
"y": to_mm(pos.y) if pos else 0,