Brep Component: Functionality and Code


I’m trying to select and keep track of brep objects using only Rhino Python script in Rhino 6, without using the Brep component in Grasshopper. To do this, I was wondering exactly what the Brep component in Grasshopper does and how pieces of its functionality can be scripted. My understanding of this is what I have written below. Would very much appreciate any feedback.

To my understanding, the Brep component allows only valid brep objects (to be selected by the user) as input. I was thinking this could be substituted by repeated rs.GetObject (where rs is short for rhinoscriptsyntax) calls and rs.IsBrep checks.

Since the Brep component also returns the brep objects, I’m thinking that the guids returned by rs.GetObject would also need to be converted to the geometric objects they represent using rs.coercegeometry.

Does this scripting seem to be on the right track? Does it cover the functionality of the Brep component (minus advanced features such as the ability to manage/view the details of the breps selected)?

Thanks you so much!

Hi @annasong,

Are you using Python by itself or are you is it in Grasshopper using a GHPython script component?

The Brep componet in GH can reference a Brep in document. Or you create a Brep in GH and feed it to a Brep component. Breps created “on the fly” or in memory do not have GUIDs.

Keep in mind that rhinoscriptsyntax is designed to be a clone of RhinoScript, so as to make it easier for those scripters to migrate to Python. Under the hood, rhinoscriptsyntax just calls RhinoCommon functions like Grasshopper does.

Does this help? Is there a bigger question?

– Dale

1 Like

Hi @dale ,

Yes, this helps a lot, though I still have a few sources of confusion. I am scripting in the Python editor that pops up when I type “EditPythonScript” as a command in Rhino. I want to replicate in this environment the functionality of the Brep component in Grasshopper when the input is an established object in the currently open Rhino screen/file.

So far, my code is:

guid = rs.GetObject("Please select a building.")
if guid is not None and rs.IsBrep(guid):
    brep = rs.coercebrep(guid)

for a single component, but I have found a discrepancy between the output from the code above and from the Brep component in GH for an object in Rhino. Specifically,


yields a different value between the two. This has led me to believe that the Brep component does something different from my code above.

Again, thanks so much for your help.

Hi @annasong,

If you want to see exactly what rhinoscriptsyntax is doing, then open Windows Explorer and navigate this this folder:

Rhino 6:

%APPDATA%\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript

Rhino 5:

%APPDATA%\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript

You will find all of the coerce functions, for example, in

In your first code sample, you’re picking a Brep object from the document. In the second example, you are creating a Brep object in memory. The Grasshopper Brep component can reference both, as when it’s all said and done it’s just a Brep.

– Dale

Hi @dale,

Yeah, I looked in the rhinoscript folder. Would you happen to know where I can find the code for the Rhino.Geometry class? I ask this because the rhinoscriptsyntax.coercebrep(guid) method calls extrusion_obj.ToBrep(False) method when the guid is that of an Extrusion object.

In the second example code, the output_brep_obj is the brep object I receive from rs.coercebrep(guid). The line of code in the second example outputs a different value than if I select the same object (from which I got the guid) in the document as the input to the GH Brep component and then call GetBoundingBox…Min.Z on the output of the Brep component. I believe this indicates that the GH Brep component runs on code that is more complicated than rs.coercebrep. Is there anywhere I can find the code for the GH Brep component or at least a very detailed description of what it does to its input?


Hi @annasong

This namespace is included in RhinoCommon, which is written in C#. You won’t find the the source on your system as it it’s compiled into the rhinocommon.dll assembly. But the you can view the Rhino 5 version here:

Sure of course. Extrusion objects can be represented a Breps.

I agree.

No, Grasshopper is not open-source.

– Dale

1 Like

Hi @dale,

Thank you so much! This clarifies the situation a lot.

Much appreciated.

Hi @dale,

I’m sorry if there’s a very obvious answer to this question: on the RhinoCommon GitHub page (, where should I look for a specific method I have in mind, say Brep.GetBoundingBox? Is there some methodology to looking through the folders to find methods?

I thought it might be in the on_brep file in the c folder, but there I only found methods that call GetBoundingBox.


Hi @annasong,

It might be easiest to just clone the repository, open the Rhino3dmIo.sln solution in Visual Studio and search for what you are looking for.

– Dale

Got it, thanks!