Bounding boxes for trimmed surfaces?

I’ve noticed when using rhino3dm.File3dmObject.Geometry.GetBoundingBox() the box returned ignores surface trimming, and encompasses control points for curves.

I fear I’m asking a dumb question, but how can I work around this and get bounding boxes that don’t include control points / untrimmed portions of objects?

try shrinktrimmedsurfaces

This functionality isn’t available in stand alone rhinod3m. If you have a render mesh attached to your Brep, you can use the mesh’s bounding box to get a tighter bbox.

Hi @stevebaer , what about in Compute? Is it available there?

Yes, compute can handle this.

Thanks Steve. I can’t find it in Compute?

Hey @fergus.hudson, here are a few options…

import compute_rhino3d.Util
import compute_rhino3d.Mesh
from rhino3dm import File3dm, MeshType

# compute_rhino3d.Util.url = ''

f = File3dm.Read('trim.3dm')

brep = f.Objects[0].Geometry # get trimmed surface

# option 1. - bounding box from trimmed surface (ignores trim)

a = brep.GetBoundingBox()

# option 2. - bounding box from render mesh (might not be present)

mesh = brep.Faces[0].GetMesh(MeshType.Any)
b = mesh.GetBoundingBox()

# option 3. - use compute to mesh surface, then get bounding box (if you don't have a render mesh)

c = compute_rhino3d.Mesh.CreateFromBrep(brep)[0].GetBoundingBox()

n = File3dm()
n.Write('box.3dm', 7)

print('Saved to box.3dm')

trim.3dm (2.9 MB)

In theory it should be possible to use compute to calculate the accurate bounding box directly, but I couldn’t see it. We’ll have to look into that!

1 Like

I just updated compute to properly handle computing an accurate bounding box for all geometry types. There was some code in compute.rhino3d that was not properly deserializing to the GeometryBase class from JSON.

The python client library has been updated on at
and the docs on the next function can be found at

I have also updated the C# client library available at
The javascript client has also been updated at

I apologise for being dense @stevebaer but are you able to provide a 2 or 3 line example?

I cannot get it to work for me. compute_rhino3d.GeometryBase is abstract, and compute_rhino3d.Brep (for example) doesn’t implement GetBoundingBox( … ).

(rhino3dm.Brep does but that’s the untrimmed version)