GhPython

For designers who want to use the same flexible language everywhere, GhPython is the Python interpreter component for Grasshopper that allows to execute dynamic scripts of any type. Unlike other scripting components, GhPython allows to use the rhinoscriptsyntax to start scripting without needing to be a programmer. Once on-board and with some practice, you can also get the most of external Python and .Net modules and libraries.

This component is open-source, and works in Rhino 5. Join this group to receive updates of new versions, and visit the Grasshopper forum for support.

To install:

  • In Grasshopper, choose File > Special Folders > Components folder. Save the gha file there.
  • Right-click the file > Properties > make sure there is no "blocked" text
  • Restart Rhino and Grasshopper

Support Email: 4FQ.RYY3Q4@HY.UQYK@
Plug-in rating:
4.625
Average: 4.6 (72 votes)
Downloads:
Title Release Notes
0.6.0.3 Grasshopper Components as Functions
2014-Jul-23
Provides a new ghpythonlib module to access all Grasshopper components as functions. Also, gives access to the current DataAccessManager (geeky). Recommended Rhino SR9 and GH 0.9.0075 or later.  
59150 downloads
Version: 0.6.0.3
Language: English
0.5.101 New Coding location - For Grasshopper 0.9.0061
2013-Dec-09
Fixes an error that was appearing on some machines the first time the component is executed  
5041 downloads
Version: 0.5.101.0
Language: English
0.5.99 Coding location - For Grasshopper 0.9.0061
2013-Dec-09
For Grasshopper 0.9.0061. Shows the location where the editor is linked. Code input and out output are again supported in Grasshopper. Several other bugfixes and improvements.  
1032 downloads
Version: 0.5.99.0
Language: English
0.5.1.0 - For Grasshopper 0.9.6
2013-Oct-23
Compatibility update for working with GH 0.9.6 and above  
15403 downloads
Version: 0.5.1.0
Language: English
0.5.0 Descriptions - For Grasshopper 0.8.66
2013-Oct-23
This release fixes several bugs and allows to set descriptions for the component and for input and output parameters, as well as overriding the help file through Python docstrings. Bug fix list https://github.com/mcneel/ghpython/issues?state=closed  
4578 downloads
Version: 0.5.0.0
Language: English
0.4.6.0 - For Grasshopper 0.8.50
2012-Jun-11
This release is published to support Grasshopper 0.8.50. Grasshopper 0.8.13 and earlier are not supported. Several bugfixes, including input marshallings.  
4902 downloads
Version: 0.4.6.0
Language: English
0.4.4 - Marshal & presentation
2011-Aug-06
Automatic marhalling for input and output variables with rhinoscriptsyntax component-level option. Python components now have presentation settings to improve visualization when development is finished.  
1705 downloads
Version: 0.4.4.0
Language: English
    
        
        
   
License: https://github.com/mcneel/ghpython

Comments

Hello

I'm running Rhino 5 for MAC - WIP.

Grasshopper works! Wondering if anyone has had success installing the Python Interpreter plugin for the MAC version of GH?

The downloads (above) dont seam to work.. Pretty sure I'm installing in the correct location - as I have had success installing Lunchbox.

Any help is appreciated!

Thanks!

RS

 

 

 

 

giulio@mcneel.com's picture

Hi there,

There are still quite a few details that need to be fixed. The biggest one is the editor: we need to see what we could use on the Mac, as we do not ship one there (unlike on Windows).

There might also still be some minor things to fix except that.
Please be patient: we would like to have this working soon, just like you.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

 

loyer3d's picture

It will be amazing when it's ready Giulio! We thank you in advance for working on this and are waiting patiently! ;-)

beat'em up Giulio!

thanks in advance

Hi,

I have installed the latest version of grasshopper and python but it does not seem to work for me (python). (I made sure to unblock it before placing it into the components folder).

It shows up in my toolbar but does not work properly. I cannot drag it in from the toolbar and when i type it in and select it, nothing happens. An older script that had the python component shows this error:

"1. Solution exception:Method not found: 'Rhino.PlugIns.PlugIn Rhino.PlugIns.PlugIn.Find(System.Guid)'."

 

Best,

 

John

giulio@mcneel.com's picture

Hi John

this is likely just an issue with an old version of Rhino. Please update Rhino 5 and let me know.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Updating Rhino solved my problems :)

Thanks!

afshin.koupaei's picture

hey I want to use decorators in ghPython ... but it seems that ghPython does not support Python Decorators.. is there trick that enables decorators for the component ?

Best 

Afshin 

afshin.koupaei@gmail.com

giulio@mcneel.com's picture

I am working on this report directly with Afshin. I will post any finding here later.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

giulio@mcneel.com's picture

This is just a quick report of the findings. The issue discovered by Afshin is due to IronPython precisely adhering to Python 2.7 conventions. If the class is a new class, decorators will work. If the class does not inherit from object, decorators will not work.

More background is discussed on this stackoverflow page.

Afshin mentioned that now some interpreters will have the Python 3 convention also work with 2.7 releases.

Hi, I downloaded the python plugin, but when I try to drag it into the canvas it appear just a single yellow panel with random characters inside, any idea?
(actually it works just the first time in any new grasshopper session, the second time I try to drag it in the canvas doesn't work anymore)

giulio@mcneel.com's picture

Hi Rikkarlo

I have seen this problem with really old Service Releases of Rhino 5. Please check that Rhino is up-to-date.

Thanks

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Thank you

hi there.

I have a problem with the installation of python. I have GH 0.9.16 (very old version) and when Im trying to install Python, this doesnt works. Do you know what might be the problem. And when i tried to install the new GH version I have this message "This package is not compatible with the Rhino Installer Engine"

thanks

José

giulio@mcneel.com's picture

Hi José

from your description, it does not sound like you are having issues with Python, but with installing the most up-to-date Grasshopper. I would suggest you make sure you have the latest version of Rhino 5, which you can download from here. Then, please let me know how it goes.

You can also contact tech.eu@mcneel.com regarding installation issues.

Thanks

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hi,

I'm wondering if there is a chance that the next python update allows to use matplotlib or numpy? That would be great. I've seen the workarounds in order to get it manually imported but unfortunately couldn't get it working so far. If there is a newer tutorial it would be great if you could share it.

Thanks

Christian

Details of various install failures I have made a notebook of here:

http://www.grasshopper3d.com/forum/topics/scipy-and-numpy?commentId=2985...

 

We need Rhino/Grasshopper Python 3.x in a 64 bit package that comes with Numpy/Scipy. Otherwise the existing system is becoming more and more obsolete according to various forums about IronPython and Numpy.

giulio@mcneel.com's picture

Hi Christian

discourse.mcneel.com/t/numpy/12912/9

this post on McNeel discouse shows the most recent information I have about using NumPy in Rhino 5 32-bit, with frames enabled.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hi All,

Is there a documentation for the ghpythonlib module as that for the rhinoscriptsyntax ?

Thanks,

 

giulio@mcneel.com's picture

Hi fbarazi,

the ghpythonlib module is built automatically departing from components that are installed in your Grasshopper. As such, it entirely follows GH functionality. There is no current plan for manual documentation, as this module is here more to aid transition/interoperability with Grasshopper than as a suggested long-term development framework.

Where do you think it would need documentation the most?

Thanks,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Thanks Giulio,

the functions based on the components are clear. However, things like instantiating Data Trees ( where you have to import several modules ) I guess require more clarification for the not so geekish who are interested in the geekish ( The SDK is VB and C# oriented).

Thanks for the great work ,

 

giulio@mcneel.com's picture

Hi again fbarazi,

I definetly understand what you mean now. Adding Python samples to the Grasshopper SDK is something I think we definetly want to tackle.

As things stand, you can see this topic regarding tree functionality and this one for converting functions from and to standard Python lists of lists. I hope this is in some way helpful,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hi!

I have been going through fora for ages now without finding an answer. I want to install GHPython for Rhino without Grashopper, on a Mac. I moved the ghpython.gha to the Rhinocerus script folder but when I type command RunPythonScript in Rhino 5 for mac, the file is unabled. Any idea? I'm very desparate at this point.

Weronika

giulio@mcneel.com's picture

Hi Weronika

GhPython, like all other Grasshopper extensions, works only where Grasshoper is installed. This means that it is currently not possible to install it on Rhino for Mac.

You should still be able to run Python scripts that do not target Grasshopper or the Grasshopper component modules. If not, the best place to ask is this category.

I hope this helps,

Giulio

loyer3d's picture

Ciao Giulio,

Now that GH exists on Mac, will we be seeing a version of GHPython for OSX any time soon? It would be a wonderfull world if it existed.

Best,

-Alex

tonywhite1989's picture

Thank you! 

nywcheng's picture

Giulio Piacentino, I had Ladybug running fine previously with earlier versions of RH & GH & GHPython, but now I can't get it to work.  I tried both the 5.0.1 and the newest 6.0.3 GhPython.gha, can't get the test files to work.  Both Rhino 5.0 (5.9.40609) and GH (.9.0076) are up to date, everything is unblocked using Streams.exe from Microsoft, closed and restarted several times.  http://api.ning.com/files/Ga2iaGVWnSGxuRErb-oBcgUPqmIasYr4Vh5-KtNsmwztsY...

Your help would be greatly appreciated.

Nancy

giulio@mcneel.com's picture

For the sake of completeness, Nancy solved the problem by re-enabling the IronPython plug-in of Rhino, which had been disabled, and updating. This fixed the issue. Thanks,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giuliomcneel.com

Hi everybody,
it's a basic question but I'd like to know whether grasshopper matches with python 2 or python 3?
tnx

giulio@mcneel.com's picture

Hi Arash,

in Rhino 5, this is Python 2 with some of the features of 3, most notably the upcoming version of division that you get with "from __future__ import division". I hope this helps,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Jeroen Janssen's picture

Hi,

 

Have you checked if you're running the latest SR of Rhino? It sounds like the same problem I had and updating Rhino 5 worked for me.

 

Best,

Jeroen
 

giulio@mcneel.com's picture

Thank you very much Jeroen, your assistance helped solving the issue with Parkerjfoo's file loading.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

parkerjfoo's picture

Hi, have gh 0.9.0075 and ghpython 0.6.0.3 installed. They were working fine, but now ghpython component fails to deserialize when i try to place it. Actually, I have an instance placed and it is working fine, but if I try to place another or copy/paste the one that is there, or open up a new document and try to place it fails. My friend is having the same problem with same file versions. Is this a known bug?

Thank you. 

giulio@mcneel.com's picture

Hi Parkerjfoo,

I am not aware of this problem and it does not happen here. Just to make sure: are you reading the file version from the lower right corner of the Grasshopper editor and the GhPython editor? If so, could you send me an email with a sample of the file that gives the issue?

Thanks

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

parkerjfoo's picture

Hi Giulio,

Yes, file versions in lower right corners of editors. I'm not having problem with any particular file. I can't place component in any file, even empty file. It seems that the problem is only with placing the component. That is, i can open file with component already placed and it functions as expected, but if I try to place a new instance by dragging from toolbar or copy and pasting existing, it fails to deserialize. 

Thanks

giulio@mcneel.com's picture

Would you be able to send me a screenshot of the error message that you get about serializing, and a file saved by you that contains a GhPython component? I would like to go to the bottom of this.

Thank you.
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

parkerjfoo's picture

Hi Giulio, I email you an empty file with two python components placed, one existing works fine, the other new one fails and appears as panel (with error code I’m guessing). The error message occurs when I try to copy and paste ghpython component and/or sometimes when I try to open a file with python components in it, but not always.

Thanks again

 

 

parkerjfoo's picture

Hi Giulio, Thanks again for your help. Update resolved issue.

*Problem was with rhino5(64) SR5. Update to SR9 fixed problem.*

cheers!

This comment has been deleted.

giulio@mcneel.com's picture

The solution for this was right-clicking the file, and choosing Unblock.
http://discourse.mcneel.com/t/hi-the-problem-about-ghpython-gha/7026

NNOWROUZ's picture

Hello,

I am having a problem with installing python on my machine at work. I am using Rhino 5 and the latest version of GH. 

I have uploaded an image of the error in the GH forum. Here is the link:

http://www.grasshopper3d.com/forum/topics/python-installation-issue

Please let me know if you have a solution to this.

Thanks,

Naciem

 

agneesh's picture

Hello,

Pardon my ignorance. I'm just getting into scripting. Does python work only on Rhino 5?

i have downloaded python (early version) component and installed in GH. However, nothing happens.

When i type _editpythonscript in rhino command line it says 'unkown command'. 

How do i even start? :(

 

Thanks

Agneesh

 

Steve Baer's picture

Yes, python only works in Rhino 5. It is not supported in Rhino 4

diegope's picture

hey agneesh

it depends if you want to use it within grasshopper (right click on the gh component and choose open editor) or if you want to write code from the python scripting editor (in which case wou wirte editpythonscript on the command line outside of gh). a good place to start understanding what is going on would be: 

http://wiki.mcneel.com/developer/python

do check the rhinopython 101. also look at the rhino python forums if specific questions arise

http://discourse.mcneel.com/category/scripting

best d

hamia's picture

Hi,

 

Does anyone know what's the equivalent code python for this:

 

var te = RhinoDoc.ActiveDoc.Objects.AddText(content, pl, size, face, bold, italics);

Rhino.DocObjects.TextObject txt = RhinoDoc.ActiveDoc.Objects.Find(te) as Rhino.DocObjects.TextObject;

 

thanks . . .

Steve Baer's picture
Jeroen Janssen's picture

Hi,

I'm running Rhino5 5.1.20927.2215, 09/27/2012 with GH 0.9.0065 and the latest ghPython component 0.6.0.3.

If I click on the component in the component bar and try to place a new component on the canvas, there's no component showing up.

I managed to place one earlier, but when I try to copy/paste this component I get an error that there is one unrecognized object in the file, the python interpreter plug-in.

Any thoughts how this can be fixed?

Many thanks!

Jeroen

giulio@mcneel.com's picture

Hi Jeroen

I think this is might have to do with the outdated Rhinoceros 5 version. Can you please update to at least Rhino 5 SR6 from Oct 28 2013?

Thanks!

claudemit's picture

hi

I have updated the rhino5 x64 to SR7 and GH 0.9007, but still can't place the newest python component on canvas.

giulio@mcneel.com's picture

Hi Claude

 GH 0.9007 is very old now. Please update to Grasshopper 0.9.0064, or more (now there's 0.9.0070). If you have any problem, please do not hesitate to email me.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Protected Collaborative Environments Wildcard SSL Certificates
© 2016McNeel Europe. User-submitted content and trademarks property of their respective owners.