Rhino Common and Python "Box.Z"

I’m trying to access the Rhino.Geometry.Box.Z method to give the Z height of a bounding box, but can’t get a handle on the syntax for using Rhino Common functions with Python. Can anyone explain? preferably with an example.

Hi Adam,

Not a true answer but to get the max Z of a Boundingbox as returned by rhinoscriptsyntax try this:

import rhinoscriptsyntax as rs

def Main():
    obj_id = rs.GetObject('getobject for boundingbox')
    if not obj_id: return 
    bbox = rs.BoundingBox(obj_id)
    #get Z value of the bbox first upper corner
    print bbox[4].Z

Does that help?

Yes, perfect, I’m still curious about how I can use rhinocommon methods with python, but this does what i’m after.

In Grasshopper this works:

- I have a box connected to a Python component
- The input is called 'Box'
- Type hint is 'Box'

Here is another mix of rhinoscriptsyntax (just to select the object) and RhinoCommon…

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def TestGetBB():
    objID=rs.GetObject("Select object for bounding box",preselect=True)
    if not objID: return
    if bb: print "Bounding box max Z is {}".format(bb.Max.Z)
1 Like

interesting. Can you point me to any good resources for understanding the rhino common syntax in rhino.python? the googles is kind of failing me on this one.

You can start here:

The API reference with all the classes is here:


You will need to understand at least a little how Python’s object oriented programming syntax works.

HTH, --Mitch