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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user