Use RhinoCommon(python) to select all objects in Rhino file

I’m sure this is incredibly simple but I haven’t been able to get it to work…

I have a Rhino file with several objects (points, breps, lines, etc.). I’d like to be able to access these objects in a python component using RhinoCommon, so that I can use them as if they had been referenced in Grasshopper (i.e. I can Transform them, visualize them, or call any of the usual methods associated with their relevant class).

I’ve tried things like Rhino.DocObjects.BrepObject.Geometry, but that just returns a IronPython.Runtime.Types.ReflectedProperty, not the geometry. I’ve also tried Rhino.DocObjects.ObjRef() and entered the guid as the argument, but I can’t seem to format the string as a guid… Any help would be greatly appreciated.


Hi @jason.danforth,
All objects in the document are stored in the ObjectTable (Rhino.DocObjects.Tables.ObjectTable). If you just want to select them, you can loop through them and use ObjectTable.Select() method

import Rhino

for rObj in Rhino.RhinoDoc.ActiveDoc.Objects:
    if rObj.IsNormal:

rObj.IsNormal condition is used assuming that you want to acces objects that are not hidden or locked.

you can acess the underlying geometry of objects from RhinoObject.Geometry property. if you want to do something to the geometry, then

import Rhino

for rObj in Rhino.RhinoDoc.ActiveDoc.Objects:
    if rObj.IsNormal:
        if(rObj.ObjectType == Rhino.DocObjects.ObjectType.Brep):
            brep= rObj.Geometry
            ##do something for breps
        elif(rObj.ObjectType == Rhino.DocObjects.ObjectType.Curve):
            curve = rObj.Geometry
            ##Do somthing for curves
1 Like


Thanks so much. This works great. I have two follow-up questions to further my understanding in general:

  1. I’m a little confused about the documentation. Rhino.RhinoDoc.ActiveDoc is listed as a property, without a description of the Objects method. How would I have figured out your suggestion on my own from reading the docs?

  2. What’s the best way to access individual objects by their GUID, assuming I want to operate on the object and not just select it?

Thanks for you help!

  1. I’m not sure what exactly you want to know. If you are totally new to RhinoCommon, then it would take some time to go through the API. You just have to experiment. RhinoDoc.ActiveDoc is a static property of RhinoDoc, which is an instance of the current active Rhino document you are working with. RhinoDoc.Objects is not a method, it is a property of the RhinoDoc instance

  2. You must loop through objects in ObjectTable

import Rhino
for rObj in Rhino.RhinoDoc.ActiveDoc.Objects:
    id = rObj.Id

Thanks so much @Darryl_Menezes. I didn’t realize RhinoDoc.ActiveDoc was an instance of RhinoDoc, so I read RhinoDoc.ActiveDoc.Objects as a property of a property (which was confusing). It’s fairly obvious now…

Re: question 2, I found what I was missing in this thread. I’ll leave my code below for the next noob trying to access a specific geometry object by GUID:

import Rhino
import System

guid_string = 'b64fa0bd-28f0-4894-baa7-ae1937d3e124'
guid = System.Guid.Parse(guid_string)

for rObj in Rhino.RhinoDoc.ActiveDoc.Objects:
    if rObj.Id == guid:
        my_brep = rObj.Geometry

a = my_brep

Thanks for getting me sorted out!