Skip to content
May 2, 2011 / stevebaer

Python component for Grasshopper

Giulio Piacentino and I have been working on an update to the grasshopper/python component and finally have something to show off!!!

http://www.food4rhino.com/project/ghpython – NOTE: Will only work in Rhino 5

This component is a scripting component similar to the VB.NET and C# components that ship with Grasshopper. You get a component where you can define as many input and output variables as you want and then reference these variables in the python script.
ghpython
If you double click on the component, you get a light version of the python script editor which you are used to in the EditPythonScript command (keywords are colorized and functions autocomplete when possible)
ghpython_editor

But there is a cool twist… this component supports the rhinoscriptsyntax functions. The rhinoscriptsyntax functions can be set to generate geometry inside of Grasshopper that does not live in the Rhino document. We are using a concept called “duck typing” to swap the document that the rhinoscriptsyntax functions use from the rhino document to a grasshopper document. This means that the following script

import rhinoscriptsyntax as rs
for x in range(10):
    rs.AddPoint((x,0,0)

will add 10 points to the Rhino document when run from Rhino’s “RunPythonScript” or “EditPythonScript” functions. The same script will add 10 points to a grasshopper document that can be passed on to other grasshopper components when run inside the syntax of grasshopper.

We are writing this as an open source project which is hosted at
https://github.com/mcneel/ghpython
Developers are welcome to download, compile, and tinker with the component source code. If you find bugs or want to add features, let us know and we’ll figure out how to get you more involved in the development process.

You can also log bugs and wishlist items at
https://github.com/mcneel/ghpython/issues

Use your python scripting skills in Rhino 5 for Windows, Rhino 5 for Mac, and in Grasshopper for Rhino 5;)
Thanks,
-Steve

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: