Rhino Python Notes

The Rhinoceros CAD system from Robert McNeel and Associates includes an IronPython scripting system with access to the GUI and the geometry engine. The following general notes may help you orient you for writing Python code to use with Rhino.

The first confusion is that Rhino can run Python scripts directly without Grasshopper, but we frequently are invoking Python scripts from GhPython blocks inside Grasshopper. The GhPython wrapper automatically translates some data from Grasshopper/Rhino to Python and back while evaluating a block. So while the same low-level operations are available in both cases, the GhPython scripts can also access Grasshopper data.

A second confusion is that there are several levels of API available. The lowest RhinoCommon level offers direct access to Rhino data structures and the current document. However, it can be convenient to use the more high-level operations available in RhinoScriptSyntax. These are themselves written in Python and the source can be found within the Rhino system. Both of these can be invoked from GhPython blocks, which also have access to the Grasshopper SDK API.

McNeel Python Documentation

A good overall starting point is the McNeel Python developer docs:

McNeel has a basic primer book (from 2011) available for a structured tutorial:

RhinoScriptSyntax has the most friendly set of operations for general scripting:

When using GhPython, the Grasshopper API is useful for manipulating Grasshopper-specific data such as data trees:

The main development guide for writing Rhino plugins, primarily oriented around the C# API:

The nitty-gritty low-level Rhino API details are written for C# and Visual Basic .NET access, but these classes mostly appear to be available via the RhinoPython interface:

GhPython to date has been available as an extra package, but is apparently going to migrate into the mainstream in a future release. The source repository: