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
Downloads:
|
Title |
Release Notes |
|
|
0.5.1.0 - For Grasshopper 0.9.6
2012-Aug-20 |
Compatibility update for working with GH 0.9.6 and above |
9504 downloads
Version: 0.5.1.0
Language: English |
|
0.5.0 Descriptions - For Grasshopper 0.8.66
2012-Jun-19 |
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 |
3322 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. |
4283 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. |
1355 downloads
Version: 0.4.4.0
Language: English |
License:
https://github.com/mcneel/ghpython
Comments
Has anyone resolved this issue that old python components now show up 'blank' without the code inside of them in newest version?
ugh ugly problem here. when i open my GH definition which contains lots of GHPython components, i get a message "Unrecognized Objects" saying my Python Interpreter Plugin is missing. Did nothing to my computer, last week it was working fine. any hints?
Rhino Version 5 (5.1.30129.1756, 01/29/2013)
GH version 0.9.0014
Thanks!!
and, all my GHPython components on stage are gone!
Just upgraded to Rhino 5 and latest ghPython (0.5.1.0 - For Grasshopper 0.9.6)
64-bit
I just tried to open my grasshopper files and they work except for my python components. I open them and they are blank. Also in the gh editor the python components are marked with a red stamp over the names that say old.
Hi Jake,
old ghPython component remains as "Obsolete" by compatibility, so the OLD label is shown, but it must work anyway.
The old python code may appear as an input for the old component. Does it appear as "Code" input value? You can see looking at "Set Multiple Data Items" at "Code" input.
Hope this helps.
Thanks,
The Python components do not work. But I was able to get access to the code I had written for the component by going into "Set Multiple Data Items" like you suggested.
For a quick workaround I just built a new Python component, copied the code into it and set up my input and output parameters to match the original component.
I guess a few other people were having trouble with the same issue and they are working on it.
http://www.grasshopper3d.com/forum/topics/rhino-5-upgrade-blank-ghrhino-...
Also I address a bug with copying and pasting Python components here:
http://www.grasshopper3d.com/forum/topics/python-component-s-presentatio...
Hi-
Not having luck with installing v0.5.1.0 I'm in Rhino 4 SR 9, GH v.9.0014
I've followed these instructions, and am not seeing the new component under Math
-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
I have subsequently installed both Python & Iron Python with no luck either.
Thoughts? Thanks!
Marc
You need Rhino 5 to use ghPython.
Hello all,
I have just tried to download and install, it's on my C drive: C:\Users\..........\AppData\Roaming\Grasshopper\Libraries\GhPython.gha, but simply doesn't run :(, no errors, but simply not showing up.
I'm using Rhino 5 and GH version 0.9.0012.
Any advise will be highly appreceated.
Same error here :(...I can't get the plugin running (Rhino5 SR0 final version)
Same error here :(...I can't get the plugin running (Rhino5 SR0 final version)
open Rhino. type Grasshopper. switch to windows exploer, browse to that .GHA file. Drag the .GHA file onto the grasshopper window (main work space) new buttons should appear.
Do you have other working components in this directory? I'm assuming you are not seeing the python icon next to the C# and VB icons in grasshopper. Is that correct?
Thanks,
-Steve
Hello Steve,
Thank you for your reply. I don't have any other components in the folder and yes, you are right, python icon doesn't show up next to C# and VB.
What I have actually noticed just now is that a new tab was created called "Math" where my python icon was placed (C#, VB... are in "Maths" tab). This might seam bit inconsistent, but at least I can play around with Python now... :)
Thanks again,
Dusa
hi all
ghpython crashes whenever i try to open the editor. working with rhino 5 release 2012-09-27 & any version of gh. have tried all the latest ones... any input on this?
best,
d
Same problem here.
Is there any message posted about what the error is?
I have just downloaded and installed, but I get an error immediately:
An error occured during GHA assembly loading:
Path: C:\Users\nedrr\AppData\Roaming\Grasshopper\Libraries\GhPython.gha
Exception System.TypeLoadException:
Message: Could not load type 'System.Func`1' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Any advice??
Thanks.
Same problem
An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
I have other copies of IronPython installed on the computer integrated with Visual Studio shell - could that be the problem????
Sure would like to use plugin - getting pretty adept at Python
I added a config file as per MS instructions - no error but the plugin does not load.
config file as per naming convention for CAS policy - Rhino.exe.config - in Rhino.... System directory
<?xml version ="1.0"?>
Did you try moving the component from a network location? Is it in a network location?
Is your component in a network location? If so, does it work if you move it to a local location?
Are you trying to run this in Rhino 4? The ghPython component only works in Rhino 5.
Using Rhino 5 and moved the component to a directory under My Documents folder and still get the .Net error. Followed the MS recommendations - unblocked the file and added a CAS configuration file which got rid of the error message but the component still does not load.
This is probably a application coding error as there is a C# or .net load command that precludes this kind of error.
Solved - reinstalled the latest version of Grasshopper - had assumed that since I had installed the latest version of Rhino 5 that GH was automatically updated as well.
So to all those not able to see the GhPython add-on - reinstall latest version of Grasshopper.
I downloaded the new Python and it seems to not have an add to Rhino Document option (as referenced in this post: http://www.grasshopper3d.com/forum/topics/this-call-is-not-supported-fro...)
Is there a work around? Thanks,
Erick
OK, I found the answer here, although the work around is a little confusing: https://github.com/mcneel/ghpython/issues/27
Hi,
Will this component be updated? It seems that it no longer works with Grasshopper 0.9.0005.
Thanks, Diederik
I just posted an update
http://www.grasshopper3d.com/forum/topics/python-component-updated-for-g...
Hi I have asked this same question on rhino.python page and got no answer.
When using Komodo Edit, for mac. How can I make this IDE provide me with information on the methods that are being implemented. I have use the Windows Python editor and I know the lower part displays this information on methods.
ie: rs.AddPoint()
| |
| |
\ /
\ /
INFORMATION:
What does you have to input? What does it returns?Those it returns it as a tupple, list, etc...?
I replied to your question on the rhino.python blog post where you originally asked the question.
http://python.rhino3d.com/entries/363-Komodo-Edit-on-Mac-and-RhinoPython...
I don't have an answer since I didn't write the KomodoEdit editor. I would recommend looking through their help reference or directly asking ActiveState.
Thanks,
-Steve
Hi, just a few words.
The advantage of GH platform is to provide users a set of tools to allow them do the programme thing without programming. So compared with python script, the GHpython component actually combines other components in GH, reducing the scripting part to the minimum, making the process of design much more flexible and efficient.
However, ghpython provide no dubugger system or exterior editor port that make the scripting part in ghpython an unhappy process.
Looking forward to see the change and really thanks for the component.
Hi, I was wondering if it is possible to to write codes in exterior editors like vim or emacs?
Actually, the original editor is not easy to use.
Yes, you can. The original editor is the same of the EditPythonScript editor. Please refer to http://python.rhino3d.com/entries/12-Configuring-Pydev-for-Rhino.Python or http://python.rhino3d.com/entries/363-Komodo-Edit-on-Mac-and-RhinoPython for examples.
Thanks for your reply.
Yep, I've seen the post before.
Actually I intend to use an editor but not an IDE.
I've also ask this question on rhino python forum but got no reply.
http://python.rhino3d.com/threads/989-How-to-customize-key-bindings-of-R...
Perhaps some "port" can be made that can allow any editor to get through? just like how processing did?
The plugin is quite enjoyable for it allows users without much programming experience to get into the software as fast as possible.
hallo,
is there any method in the python component that returns polygons with more than five vertices?
i need it to transfer data from houdini to grasshopper. houdini is polygon-based and works with polys that have more than 5 vertices.
houdini can write out point numbers, coordinates and face-vertices etc.
I tried the following methods:
rs.AddPlanarSrf() (ONLY PENTAGONS)
rs.AddPlanarMesh() (ONLY PENTAGONS DIVIDED INTO TRIANGLES)
rs.MeshPlane() (DID NOT WORK AT ALL)
similar question was asked by gerd fechter in:
http://www.grasshopper3d.com/forum/topics/python-mesh-or-plane-form-poly...
Hi Nils
I've answered Gerd's question on the Grasshopper forum.
rs.AddPlanarSrf() seems to works well. You need to input a planar surface, though. I believe the pentagon doubt comes from there.
Meshes in Rhino can only contain triangles and quads. So the only real choices left are polylines and NURBS patchs.
You can create a patch like so:
import Rhino
a = Rhino.Geometry.Brep.CreatePatch(x, 12, 12, 0.01)
#where x is a list of curves. Use rs.coercecurve() for each guid if using rs
if a is not None:
....a = ghdoc.Objects.AddBrep(a)
I hope it helps,
- Giulio
_________________
giulio@mcneel.com
Hi,
Is there a bug with the AddPlanarSrf?
Doesn t seem to create any surfaces from the same curves that AddPlanarMesh works perfectly fine.
Thanx
Hi doompop,
a quick test shows that the function works. Please note that rs.AddPlanarSrf accepts a list of curves forming a closed planar entity, while rs.AddPlanarMesh accepts a single, planar curve.
Thank you.
- Giulio
_________________
giulio@mcneel.com
Thank you Giulio,
I have in the code that:
srf1 = rs.AddPlanarSrf(circles1)
surfaces.append(srf1)
Circles1 is just a list of circles.
and i am expecting to get planar surfaces to a list of circles....but I only get in the panel the following description: IronPython.Runtime.List
I am a beginner so apologies for naive questions.
Thank you in advance!
Hi doompop
so, rs.AddPlanarSrf(ids) accepts a list of curves that will be the boundaries of one planar surface. So if you have four line segments that are consecutively adjacent and planar, in a list, when passed to the function they will form a quadrilateral.
This means that, for a circle, you should pass a list with a single circle inside, as that is the boundary already.
Thank you very much Giulio,
I must be doing something wrong because that is what I think I am doing.
I ll try again to solve this.
Cheers!
Would you post the file in a discussion on the Grasshopper forum,
http://www.grasshopper3d.com/forum/categories/vb-c-and-python-coding/lis... ?
I must say... the fact that the sample component loads with incorrectly named variables makes it extremely confusing to try to learn how to use this component.
When you drag a new Python component in to grasshopper, it loads with the default inputs named "Variable x, Variable y" and the outputs named "Results a", etc...
This example code doesn't work until you delete the "Variable" and "Result" from the name of each I/O.. just leaving "x" , "y", etc.
Hi nhfoley,
this is not what happens here... variables are named "x", "y" and "a". Are you using Rhino 5 in a version of May, Grasshopper version 0.8.66 and GhPython 0.4.6? The version numbers of Grasshopper and of GhPython appear in the lower right corner of their windows.
If you have the latest versions, or if after updating this error still happens, could you please contact me with more information at giulio@mcneel.com, or start a discussion here: http://www.grasshopper3d.com/forum/categories/vb-c-and-python-coding/lis... .
You comment is much appreciated,
- Giulio
________________
giulio@mcneel.com
I was wondering if there's some way to access the complete list of parameters passed to the Python component. For example when I pass a list of vectors to the python code as 'x', and then try and manipulate 'x', whatever I do is applied to each member of the list, not to the entire list. I understand that this is desirable in many cases and consistent with how the other GH components work, but sometimes I want to manipulate the entire list. Is there a way to do this?
Oh wait, nevermind *sheepish look* I think I found something under -> 'input manager' -> 'list access'
OK, maybe I do still need some help figuring this out. It allows me to access the list, but it doesn't recognize 'append' as an attribute. For example, this bit of code gives an error ( Solution exception: 'List[object]' object has no attribute 'append' ):
import math
import rhinoscriptsyntax as rs
x.append(x[0])
a = x
Hi Sun,
the new component for Grasshopper 0.8.50 should fix this. It returns the IronPython List type instead of the List type.
Thanks,
- Giulio