3D regular BoundingBox from python component

Hi @martinborst1,

import Rhino.Geometry as rg

pt = rg.Point3d(0, 0, 0) # or rg.Point2d.Origin (also creates a point at the origin)
bbox = mesh.GetBoundingBox(False) # or mesh.GetBoundingBox(True) for physical accuracy but slower

print bbox.Volume, bbox.MinimumCoordinate, bbox.MaximumCoordinate

I recon mesh refers to a component input? If so, you probably need to set its type hint to mesh!

Here are some links to the relevant reference pages, if you for instance want to look up some methods and/or attributes of the BoundingBox structure:



A structure, much like a class, is a data structure, a way to structure your code. In C# structures are stack allocated, which brings some performance benefits, compared to classes, which are all reference types and heap allocated. Heap allocated symbols need to be cleaned up when they run out of scope or are not needed anymore, and that’s were the garbage collector comes in. If you allocated lots of objects in heap memory, the garbage collector probably also has a lot of work to do and this entails a performance penalty, but that’s an other story really.

Honestly, I’d forget about node in code. Theoretically, it’s a nice concept, but also pretty much redundant. Use rhinoscriptsyntax or even better the API (aka RhinoCommon), like I do above.
If you have questions, just ask here or in the Scripting forum!

1 Like