GetBoundingBox Aligned to Plane

I am trying to get the bounding box of a curve aligned to a plane. If I use GetBoundingBox(True), the boxes show up in the correct location. However if I use GetBoundingBox(plane) or GetBoundingBox(transform). The bounding box is always in the wrong place.Do I need to transform the bounding box after it is created?


Hi Ryan,

Can you post all of your code and your geometry?


– Dale

Also, this is through Grasshopper Python so that might be causing the error as well. See below for some screen shots. Here is the code:

import Rhino
if len(boundaries) != len(planes):
    raise ValueError("ERROR: Boundary and Plane lists must have the same number of items!")

polylines = []

for i, b in enumerate(boundaries):
    p = planes[i]
    xform = Rhino.Geometry.Transform.ChangeBasis(p, Rhino.Geometry.Plane.WorldXY)
    bb = b.GetBoundingBox(True)

You can see below that GetBoundingBox(True) is working just fine.

You can see in the next two images that both GetBoundingBox(Plane) and GetBoundingBox(Transform) are close but 1 box is located in the wrong location and rotation.
<img src=“” width=“690” heigh t=“431”>

Finally, if I use the orient command from grasshopper to position the bounding boxes from the WorldXY plane to the new plane it is fixed But when I try to transform the boxes myself, they are incorrect(last image). It is close but not quite right.

Does this help at all? The last image is close… but it seems to distort the bounding box as it transforms it.

Hi Ryan,

Keep in mind that a BoundingBox is just a struct that contains two points: the min and max points. Its’ pretty hard to orient 2 points to anything but the world. So, you will want to get the corners of the bounding box and transform them.

You might want to consider a bounding box calculator that looks more like this:

def MyBoundingBox(geometry, plane=None):
    if plane is not None:
        # Get plane aligned bounding box
        bbox = geometry.GetBoundingBox(plane)
        # Get world x-y plane aligned bounding box
        bbox = geometry.GetBoundingBox(True)
    # Get bounding box corner points
    corners = list(bbox.GetCorners())
    # Transform from plane coordinates to world coordinates, if needed
    if plane is not None:
        world = Rhino.Geometry.Plane.WorldXY
        plane_to_world = Rhino.Geometry.Transform.ChangeBasis(plane, world)
        for pt in corners: 
    return corners

– Dale

1 Like

Well, I think I had the same realization as you did last night. I finally figured out that a bounding box isnt so much a “box” as it is data representing a box. In this case 2 points. Thanks for all the help!

I have a question about it as I’ve bumped into this issue today. Why transformation on Bbox doesn’t work properly, but works fine on its points?