Skip to content
April 13, 2010 / stevebaer

Getting started: 3 – The rhinoscript package

By now you should be able to print text to the command line and write some simple python functions, but you may be getting a little bored with that. It’s time to start working with Geometry in Rhino. This is where the rhinoscript package comes into play.

Introducing the rhinoscript package
On your computer, the rhino/python plug-in creates a directory (package) named rhinoscript which contains a number of python script files (modules).

  • On Windows, this directory is located in your local roaming user directory. You can find this directory by looking at the Paths… under the Options menu in the python editor. On my computer, this directory is
    C:\Users\a-steve\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib
  • On OSX, this directory is located in the directory created when you run the IronPython.macrhi installer. On my Mac, this directory is
    /Users/steve/Library/Application Support/McNeel/Rhinoceros/MacPlugIns/IronPython/settings/lib

These files define a large set of functions for working with Rhino. Help pages for these functions can be found at

Importing the rhinoscript package will give your script access to these functions.

# add some points to Rhino using the rhinoscript package
import rhinoscript
count = rhinoscript.userinterface.GetInteger("Number of points")
if( count!=None ):
  for i in range(count):
    x = i
    y = i
    if( i > count/2 ): y = count-i

Not too shabby, huh?

The big list –
Boy, typing all of those words to add a point and get an integer sure make my fingers tired. If you don’t like to have to type so much, there is a module included with your installation named whose sole purpose is to merge all of the rhinoscript functions into a single “namespace.” This makes it easier to use functions without having to figure out the specific module it is defined in.

# use rhinoscriptsyntax to get all the functions in one shot
import rhinoscriptsyntax as rs
count = rs.GetInteger("Number of points")
if( count!=None ):
  for i in range(count):
    x = i
    y = i
    if( i > count/2 ): y = count-i

The RhinoScript Legacy
For a long time now, Rhino for Windows has included a scripting system named “RhinoScript” and is based on the VBScript scripting language. RhinoScript includes around 1000 functions for allowing VBScripts to interact with Rhino. The python rhinoscript package was designed to mimic the functionality of this library to allow for easy transition between the two languages and because these are the functions that users have asked for.

The current state of the python rhinoscript package is somewhere around 400 functions that are matches to their VBScript counterparts. This list grows with every work-in-progress release of Rhino, based on requests from users. If there is a function that you need that is not implemented in the rhinoscript package, let me know and I’ll see what I can do to add it.

More Samples
One way to play with and learn about the functions in the rhinoscript package is by examining the online help Each function help topic includes a sample script (typically very small) that uses the function. You may want to type some of these samples in to your favorite python editor and attempt to run them.

There are also a number of sample scripts that ship Rhino. If you enter the “RunPythonScript” command, you’ll notice that there is a subdirectory named “samples” which contain scripts you can run. Almost all of these scripts use the rhinoscript package.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: