Skip to content
1 change: 1 addition & 0 deletions doc/changelog.d/1630.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Component bounding box wrong formating
9 changes: 7 additions & 2 deletions src/pyedb/common/nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,13 @@ def mirror_poly(poly):
except KeyError:
pass
cbb = comp.bounding_box
x = [cbb[0], cbb[0], cbb[2], cbb[2]]
y = [cbb[1], cbb[3], cbb[3], cbb[1]]
if isinstance(cbb, tuple):
x = [cbb[0][0], cbb[0][0], cbb[1][0], cbb[1][0]]
y = [cbb[0][1], cbb[1][1], cbb[1][1], cbb[0][1]]
else:
# falling back to list format for bbox
x = [cbb[0], cbb[0], cbb[2], cbb[2]]
y = [cbb[1], cbb[3], cbb[3], cbb[1]]
vertices = [(i, j) for i, j in zip(x, y)]
vertices = mirror_poly(vertices)
poly = Polygon(vertices)
Expand Down
12 changes: 6 additions & 6 deletions src/pyedb/grpc/database/hierarchy/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def location(self, value):
super(Component, self.__class__).location.__set__(self, _location)

@property
def bounding_box(self) -> list[float]:
def bounding_box(self) -> tuple[tuple[float, float], tuple[float, float]]:
"""Component's bounding box.

Returns
Expand All @@ -776,7 +776,7 @@ def bounding_box(self) -> list[float]:
bbox = self.component_instance.get_bbox().points
pt1 = bbox[0]
pt2 = bbox[2]
return [Value(pt1.x), Value(pt1.y), Value(pt2.x), Value(pt2.y)]
return (Value(pt1.x), Value(pt1.y)), (Value(pt2.x), Value(pt2.y))

@property
def rotation(self) -> float:
Expand Down Expand Up @@ -1199,10 +1199,10 @@ def create_clearance_on_component(self, extra_soldermask_clearance=1e-4) -> bool
bool
"""
bounding_box = self.bounding_box
opening = [bounding_box[0] - extra_soldermask_clearance]
opening.append(bounding_box[1] - extra_soldermask_clearance)
opening.append(bounding_box[2] + extra_soldermask_clearance)
opening.append(bounding_box[3] + extra_soldermask_clearance)
opening = [bounding_box[0][0] - extra_soldermask_clearance]
opening.append(bounding_box[0][1] - extra_soldermask_clearance)
opening.append(bounding_box[1][0] + extra_soldermask_clearance)
opening.append(bounding_box[1][1] + extra_soldermask_clearance)

comp_layer = self.layer
layer_names = list(self._pedb.stackup.layers.keys())
Expand Down
5 changes: 4 additions & 1 deletion src/pyedb/workflows/drc/drc.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ def _build_spatial_index(self) -> None:
for i, via in enumerate(self.edb.padstacks.instances.values()):
self.idx_vias.insert(i, via.position)
for i, comp in enumerate(self.edb.components.instances.values()):
self.idx_components.insert(i, comp.bounding_box)
comp_bbox = comp.bounding_box
if isinstance(comp_bbox, tuple):
comp_bbox = [comp_bbox[0][0], comp_bbox[0][1], comp_bbox[1][0], comp_bbox[1][1]]
self.idx_components.insert(i, comp_bbox)

def check(self, rules: Rules) -> List[Dict[str, Any]]:
"""
Expand Down
Loading