Feat: add bounding box and courtyard info to component queries (#163)

Components now include boundingBox (min/max X/Y, width, height) in
get_component_list and get_component_properties responses. The SWIG
get_component_properties also includes courtyard dimensions when the
footprint defines a courtyard layer.

SWIG backend uses GetBoundingBox() and GetCourtyard(). IPC backend
tries get_item_bounding_box(), then pad-extent fallback, then falls
back to SWIG backend data when available. This ensures bounding box
data is present regardless of which backend handles the query.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gavin Colonese
2026-05-19 09:36:33 -04:00
committed by GitHub
parent 95e23c70ff
commit f03a74a93f
4 changed files with 281 additions and 25 deletions

View File

@@ -5379,6 +5379,19 @@ print("ok")
try:
components = self.ipc_board_api.list_components()
# If IPC didn't provide bounding boxes, enrich from SWIG backend
if self.board and components and not components[0].get("boundingBox"):
try:
swig_result = self.component_commands.get_component_list(params)
if swig_result.get("success"):
swig_map = {c["reference"]: c for c in swig_result.get("components", [])}
for comp in components:
swig_comp = swig_map.get(comp.get("reference"))
if swig_comp and swig_comp.get("boundingBox"):
comp["boundingBox"] = swig_comp["boundingBox"]
except Exception:
pass
return {"success": True, "components": components, "count": len(components)}
except Exception as e:
logger.error(f"IPC get_component_list error: {e}")
@@ -5578,6 +5591,17 @@ print("ok")
if not target:
return {"success": False, "message": f"Component {reference} not found"}
# If IPC didn't provide bounding box, try SWIG backend as fallback
if not target.get("boundingBox") and self.board:
try:
swig_result = self.component_commands.get_component_properties(params)
if swig_result.get("success"):
swig_comp = swig_result.get("component", {})
target["boundingBox"] = swig_comp.get("boundingBox")
target["courtyard"] = swig_comp.get("courtyard")
except Exception:
pass
return {"success": True, "component": target}
except Exception as e:
logger.error(f"IPC get_component_properties error: {e}")