#x is a group of bounding Breps
BB = x.GetBoundingBox(Rhino.Geometry.Plane.WorldXY) #works for one object but doesn’t for a group of objects
#Python #BoundingBox #grasshopper #scripting #group
#x is a group of bounding Breps
BB = x.GetBoundingBox(Rhino.Geometry.Plane.WorldXY) #works for one object but doesn’t for a group of objects
#Python #BoundingBox #grasshopper #scripting #group
import Rhino.Geometry as rg
bbox = rg.BoundingBox.Empty
for brep in breps:
bbox.Union(brep.GetBoundingBox(rg.Plane.WorldXY))
a = bbox
bbox.gh (118.3 KB)
@Mahdiyar
Done! Thank you! Could you clarify a moment, what is really this Empty? Is it like Empty Box required for the Union method?
Exactly.
@Mahdiyar
Thanks
Not required for Union; you can perfectly fine Union one non empty bbox with another.
Yet in this case you need an initial boundingbox to union your first object bbox with.
That initial Empty bbox is the seeding container for the first bbox.
Without an Empty bbox, you could also have done this:
import Rhino.Geometry as rg
bbox = None
for brep in breps:
if bbox is None:
bbox = brep.GetBoundingBox(rg.Plane.WorldXY)
else:
bbox.Union(brep.GetBoundingBox(rg.Plane.WorldXY))
a = bbox
-Willem
@Willem
Big thanks for your clarification!