Skip to content
April 6, 2010 / stevebaer

Getting started: 1 – “Hello Rhino”

So you want to start playing with Python and see how you can use it to automate all of your Rhino tasks.

First off you are going to need either the latest Rhino 5 for Windows WIP or the latest Rhino for OSX WIP. These can be found at:

Once you’ve got everything installed Rhino will have some new commands:
EditPythonScript – This is currently only available on the Windows version of Rhino. The command displays a script editor for writing and experimenting with scripts. We’ll focus on this command some other time.
RunPythonScript – Available on both Windows and Mac. This is used to actually execute your Python scripts

The python engine for Rhino comes with a number of pre-installed samples for you to play with and run. Let’s try running one of these samples now.

  • Run the “RunPythonScript” command: this will display a file open dialog with the active directory being a scripts directory.
  • Open the samples subdirectory and choose the “CircleFromLength.py” file. If everything goes well, you should be prompted to pick and point and enter a number which will result in a new circle in Rhino.
  • Congratulations you are now a Python expert! Well… maybe there’s a bit more to learn.

I think you’re probably going to want to do more than just run my lame collection of pre-canned samples, so why don’t we try creating a very basic script run it. Python scripts are just plain text files that typically end with a .py file extension. Using your favorite text editor (plain text please, no fancy Word style documents) create a new text file and type the following into it

print "Hello Rhino"

Save this file and remember to change the file extension to .py
Now, try running the “RunPythonScript” command and select the file that you just made. If everything goes right, you should get Hello Rhino printed on the command line. I know, pretty lame…. but hey it’s a start.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: