Skip to content

Commit

Permalink
added bounding box function
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Dec 26, 2024
1 parent d850829 commit 628bbaa
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/paramak/assemblies/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,21 @@ def names(self):
for part in self:
names.append(part[1].split('/')[-1])
return names

def bounding_box(self):
# Iterate through the remaining parts and update the bounding box coordinates
for i, part in enumerate(self):
if i == 0:
first_part_bbox = part[0].BoundingBox()
bbox_min = cq.Vector(first_part_bbox.xmin, first_part_bbox.ymin, first_part_bbox.zmin)
bbox_max = cq.Vector(first_part_bbox.xmax, first_part_bbox.ymax, first_part_bbox.zmax)
else:
part_bbox = part[0].BoundingBox()
bbox_min.x = min(bbox_min.x, part_bbox.xmin)
bbox_min.y = min(bbox_min.y, part_bbox.ymin)
bbox_min.z = min(bbox_min.z, part_bbox.zmin)
bbox_max.x = max(bbox_max.x, part_bbox.xmax)
bbox_max.y = max(bbox_max.y, part_bbox.ymax)
bbox_max.z = max(bbox_max.z, part_bbox.zmax)

return (bbox_min.x, bbox_min.y, bbox_min.z), (bbox_max.x, bbox_max.y, bbox_max.z)

0 comments on commit 628bbaa

Please sign in to comment.