Skip to content

Commit 53a42a6

Browse files
committed
Merge branch 'adding-bounding-box' into adding_umesh_example
2 parents cbe7c83 + 628bbaa commit 53a42a6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/paramak/assemblies/assembly.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,21 @@ def names(self):
3535
for part in self:
3636
names.append(part[1].split('/')[-1])
3737
return names
38+
39+
def bounding_box(self):
40+
# Iterate through the remaining parts and update the bounding box coordinates
41+
for i, part in enumerate(self):
42+
if i == 0:
43+
first_part_bbox = part[0].BoundingBox()
44+
bbox_min = cq.Vector(first_part_bbox.xmin, first_part_bbox.ymin, first_part_bbox.zmin)
45+
bbox_max = cq.Vector(first_part_bbox.xmax, first_part_bbox.ymax, first_part_bbox.zmax)
46+
else:
47+
part_bbox = part[0].BoundingBox()
48+
bbox_min.x = min(bbox_min.x, part_bbox.xmin)
49+
bbox_min.y = min(bbox_min.y, part_bbox.ymin)
50+
bbox_min.z = min(bbox_min.z, part_bbox.zmin)
51+
bbox_max.x = max(bbox_max.x, part_bbox.xmax)
52+
bbox_max.y = max(bbox_max.y, part_bbox.ymax)
53+
bbox_max.z = max(bbox_max.z, part_bbox.zmax)
54+
55+
return (bbox_min.x, bbox_min.y, bbox_min.z), (bbox_max.x, bbox_max.y, bbox_max.z)

0 commit comments

Comments
 (0)