Grasshopper tools in C#
Grasshopper features an impressive amount of highly interlinked components – from lines to trees, from circles to graph editors. Sometimes, however, when design tasks become more advanced, we might need to further customize this plugin by directly borrowing from Rhino commands. With these scripting components, the user can quickly solve otherwise more complex design behaviors.
This list of C# scripts is a work in progress and is open for requests. Supporting v. 0.8.2 and some previous versions.
baking & Referencing | ||
![]() |
bakeName GH 0.6.0012 GH 0.6.0018 GH 0.6.0043 |
obj (geom) – a list of objects to bake name (string) – a list of names (common Rhino property) activate (bool) – one go-no-go signal, or a list thereof A (strings) – a list explaining the result(s) |
![]() |
bakeAttributes GH 0.6.0012 GH 0.6.0018 GH 0.6.43 GH 0.8.2 GH 0.8.7 GH 0.8.52 w/ groups GH 0.9+ w/ groups |
obj (geom) – a list of objects to bake name (string) – a list of names layer (string) – Rhino layer name(s) color (onColor) – screen+print color(s) lineT (string) – the name of a linetype. Please only use with custom names. pWidth (double) – printing thickness(es) wires (int) – number(s) setting the quantity of wires, as in the property panel material (int) – GH shader(s), containing a Rhino material activate (bool) – one go-no-go signal, or a list thereof A (strings) – a list explaining the result(s) |
findID findRef GH 0.6.0012 2009 06 19 |
x (geom) – a Rhino geometry
A (string) – The Rhino ID |
|
Automatic Sections | ||
![]() ![]() |
contours GH 0.6.0012 GH 0.6.0043 2009 06 04 |
input (geom) – the objects to contour axis (onLine) – a line identifying the origin and end of the sectioning axis dist (double) – the interval between sections geomOut (geom) – a list containing all geometries meshOut (geom) – a list containing all geometries deriving from a mesh |
Continous redrawing | ||
![]() ![]() |
theEngine
component for 2009 06 06 |
isOn (bool) – one go-no-go signal speed (int) – a period, expressed in milliseconds, that sets the refreshing rate resetAt (int) – the last shown number in the series, which will be restarting at 0stopAt (int) – the last shown number in the series starting at 0 reset (object) – any object (or bool) passed here will make this component restart from 0 C (int) – the current count |
![]() ![]() ![]() |
Buckets
GH 0.6.0012 |
x (list) – a list of points. For the bucket, it can be a list of anything. reset (object) – any object here will make this an empty list limit (OnInterval) – two numbers which set the max and min values for each internal point coordinate A (list) – the list in memory |
![]() |
renderAnimation
GH 0.6.0012 (four examples, see last one) |
geometry (list) – a list of objects to be added to the scene before rendering viewport (string) – the name of the viewport to use. If empty or non-existing, the active one will be used filePath (string) – a name of an existing folder. If empty, the folder of the open document will be used. If document not saved, the current user’s document folder will be used fileExt (string) – jpg, png, bmp, or another extension that the rendering engine supports current (int) – the sequential number of the frame A (string) – a text, explaining the outcome |
fonts | ||
![]() |
txtLines GH 0.6.0012 GH 0.8.0061 New |
face (string) – the name of the font bold (bool, default false) italics (bool, default false) size (double, default 5.0) content (string) – the text shown pt (on3dPoint) – the point ancoring the text A (OnLine list) – a list containing all curves |
Networking | ||
![]() |
updReceiver udpSender GH 0.6.0019 Processing 1.0.5 + UDP library 2009 08 31 |
port (integer) – a resonable port number
out (string list) – network echo |
May 28th, 2009 at 11:38 pm
Great definition. I had a question about the Color attribute. I had wanted to turn on that attribute for the autobake toggle… but how is the color syntax formatted? Is it something like this?
att.m_color = new OnColor(255,255,255)
where the three numbers are RGB values? Or would you include a hexidecimal value? Or is there I’m completely missing. Other than that, this definition works great. Congratulations.
May 29th, 2009 at 11:11 am
Hey Andy, glad you like it. The new “advanced” definition should now do what you asked for.
June 7th, 2009 at 5:57 pm
Amazing job! These are some great tools. Thanks for all of the hard work.
June 9th, 2009 at 1:56 am
Giulio,
Great stuff. We had Andy over here at the lab in the weekend and he pointed us in your direction. Your code blocks will be excellent starting points for the research on multi disciplinary optimization and topology we are doing.
Thanks & I’ll be sure to keep you up to date with feedback.
June 13th, 2009 at 9:12 pm
Great work on theEngine components, love ’em!
take care,
d.
July 14th, 2009 at 2:01 am
Nice work, they are very useful! Thank you very much!
P
July 19th, 2009 at 9:34 pm
hey G
these are great. to get a still instead of an animation would that be easy to get using your animation component?
regards
July 29th, 2009 at 9:37 am
Hey Giulio, great job!
Greetings from Bologna!
Best,
Alessio
July 29th, 2009 at 12:25 pm
Hi,
I am really interested with your script and trying to utilize it.
But I am having a problem with inputing your script to my C# tool.
What I am doing is just copy & paste your script into the portion named “your code”.
Could you let me know what’s wrong with it?
July 30th, 2009 at 11:28 am
There is no need to copy-and-paste, all you need to do is download the .ghx file (in some older browsers right-click the component and select “Save target as…”) and open it in Grasshopper. Should work with GH 0.6.12
August 3rd, 2009 at 12:00 pm
Hi Giulio,
similar basic question as Wansoo’s. I’ve tried opening or merging bakeAttributes. But an IO always pops up with 46 messages, mainly components failed to deserialize. Any hints on using this C# component will be helpful. Ta.
August 3rd, 2009 at 3:18 pm
Hi Andrew, there will be soon an update with hotfixes for GH 0.6.0018. That release changed some inner workings in GH, so files are now not 100% compatible with version 0.6.0012. There’s nothing to worry about, everything on this page will be compatible, or with two releases. I’m glad if anybody can help in this task.
August 20th, 2009 at 12:59 am
Hello !
Great job indeed ! Trying to use theEngine but I’m having the following error :
The type or namespace name ‘EH_SolutionCause’ does not exist in the namespace ‘Grasshopper.Kernel’ (are you missing an assembly reference?)
Even if I do not have an error with the theEngine using stopAt, nothing happens.
GH version 0.6.0018 – Rhino 4SR5 (do I need 4SR6?)
thanks !!!
August 20th, 2009 at 11:39 am
The latest compatibility release should now work!
September 2nd, 2009 at 7:02 pm
great job guilio, unfortunately i have only used the contour command… will be able to explore others in the next few weeks….
September 15th, 2009 at 4:17 pm
thanks for the C scripts, they are very very helpful …. i am using the bake attributes script, using version 06.0012
i don’t understand how the delete materials boolean works … do i need to make clusters of my objects first before baking? where does this component connect to?
many thanks
September 18th, 2009 at 8:39 pm
Hi Mei, glad to help. The “delete materials” is only intended for advanced use (if you are using really many materials). Unselect all objects in Rhino, then use the boolean command once. Save your 3dm model, close it and reopen it in Rhino. You document should not contain any material now!
September 24th, 2009 at 1:50 am
HI Giulio,
Your site is great, thanks for all the sharing. I have been trying to add the “renderAnimation” component into my grasshopper definition, but did not manage to render the animation. Basically, I want animate two walls where the sun would move over the course of a day. The hours are controlled by a slider. My question is how do I tell Rhino to render, is there a switch created by the component?
Thanks
September 25th, 2009 at 10:54 pm
many thanks giulio, will try it out …
January 30th, 2010 at 4:11 pm
great post – helpful for my grasshopper
March 11th, 2010 at 11:20 pm
Hey Giulio
Amazing set of tools, I have successfully implemented your RenderAnimation tool into my GH file, but am wondering if there is any way to assign a material to a specific geometry through the tool. I understand that it assigns an equivalent amount of materials to the amount of geometry that is inputted. Simply put, i wiould like to have half the geometry one colour, and the other have another? Can I be helped?!?!?!
thanks
March 17th, 2010 at 6:32 pm
Hi Brian, without knowing more of your definition, it’s difficult to tell which one would be the easiest method. One that comes in my mind is to use the “duplicate data” component in Grasshopper, to obtain the right amount of materials. Also, you could make a series of indexes and take the right shader from a list of two. Please let me know if I can help you further with this. -Giulio
March 25th, 2010 at 4:39 am
Giulio,
I am currently taking my first C# programming class to learn to write Grasshopper components. Ultimately I need to take what I learn from the class and implement it into GH. I am contacting you to see if you would be willing to share a C# code file with me so I might start to use it as a template to write my own C#/Grasshopper components. The best file for me to review would be any simple file to give me a sense of how it might come together. Any leads to any other resources regarding same would also be very helpful.
Thanks for considering
Sincerely,
Stan Carroll
beyondmetal.com
March 25th, 2010 at 10:50 am
Hi Stan, I’m contacting you by mail.
– Giulio
March 29th, 2010 at 5:05 pm
hi Giulio, i just discovered your render animation component and opened it in Gh. how do i activate it? thanks
hana
June 1st, 2010 at 7:54 am
Hi Giulio, I just started playing with your txtLines tool. Very Helpful definition. Is there a way to add toggles for ‘curves/face/solids’ + ‘allow single stroke fonts’ that are part of the textobject rhino method? (http://rhinotoday.com/2009/07/single-line-fonts-in-rhino/). Thanks for taking a look.
-Dan
June 2nd, 2010 at 7:30 pm
Hi Dan,
as Luis was pointing out here, the only possibility that is available at the moment is to script the command. Possibly RhinoCommon will soon overcome the current limitation, but for now, scripting the command (or doing the operation manually altogether) are the only possibilities I know of. I haven’t tried Benjamin’s definition in this discussion yet, but looks promising.
– Giulio
August 31st, 2010 at 6:59 pm
Giulio… any plans to update these tools for use with GH 0.7? Thanks.
Marc
August 31st, 2010 at 7:39 pm
Hi Marc,
in theory, Gh 0.7 should support all these scripts in the legacy component.
But if there are any problems please let me know!
Thanks,
– Giulio
September 25th, 2010 at 2:15 pm
hi giulio ,
recently switched to GH7 and tried to use component in the bakeMostAttributes-43.ghx
unfortunatly the legacy component doesn´t seem
to work. is there any way to bake colour and material in the current grasshopper 7
thx
chris
September 25th, 2010 at 3:18 pm
Hi Christoph,
which attributes are you interested in baking?
Material is difficult in the current state of RhinoCommon, but should soon be possible again, other are already possible.
– Giulio
September 25th, 2010 at 4:11 pm
thx for your fast reply
was wondering if i could render the colour output of for instance the surface curvature evaluation because i am trying create formdepend shaders.
September 25th, 2010 at 4:31 pm
The easiest way to have some procedural colors/materials on a surface is apply colors to a corresponding Mesh.
“C” input in the Mesh component are vertex colors – just set it, then the mesh can be baked even with the normal Grasshopper button.
I hope it helps,
– Giulio
October 14th, 2010 at 12:45 am
Hi Giulio,
Im an architecture student at Mcgill university. I’ve just gotten started with grasshopper a few weeks ago and I’m currently having problems trying to contour a surface.
I have a surface in Rhino, I need contour lines for this surface as if it were a topographical map. Is there any way to do this on Grasshopper?
Thanks,
Elan
October 15th, 2010 at 12:02 am
Hi Elan,
I do not have tutorials for this, but intersecting a series of planes with either a mesh or a polysurface should give the result you seek.
I remember this nice example: http://www.grasshopper3d.com/photo/contourlayout-1?context=latest
– Giulio
November 2nd, 2010 at 3:20 am
Hi Giulio,
I modified your script to work with Grasshopper 0.7. You can find it here: http://parametricmodel.com/detail.php?item=10
Daniel
November 20th, 2010 at 6:29 pm
Hi Giulio. Great Components I have to say. Thank you for sharing.
I would like to ask you something because I’m having problems with renderAnimation component in GH 0.8. Do you if I you will upgrade soon to use with 0.8 version? Thank you.
Igo
November 21st, 2010 at 2:07 am
Done, thanks for reminding me.
– Giulio
November 30th, 2010 at 9:36 pm
Hi Guilio, amazing stuff, but do you know how to make the renderAnimation component work with GH 8.0?
December 2nd, 2010 at 1:37 pm
It is, isn’t it working?
– Giulio
December 6th, 2010 at 12:16 pm
Does the renderanimation work in rhino on its own, or does it need to be rendered using sometihng like vray? i cant find the batch render option in rhino…
December 6th, 2010 at 12:37 pm
Hi Nick,
it should work for any renderer for which the _Render command works. Yes, the Batch render option is there in VRay.
– Giulio
December 6th, 2010 at 12:54 pm
Thanks for the speedy reply Guilo, unfortunatley i am a very confused. i think it may be that my university has grasshopper 6.0001, and you used 6.0002. its having a problem with timer failing to ‘deserialize’.
I will give it another go on my home computer which is uptodate.
January 5th, 2011 at 5:37 pm
Hi Giulio
I’m thinking of a bake update tool.
That is similar to the Bake Attribute tool, but that it could overwrite geometries in Rhino with new ones, identified by their names.
January 5th, 2011 at 6:16 pm
Hi Victor, please go ahead!
You can find working code for that in the RenderAnimation script. It does not keep track of names, but rather by ID (Guid) or reference. You will need to come up with a way to store the “these are baked” state in the component, though.
– Giulio
January 21st, 2011 at 8:40 pm
Hi Giulio,
I’ve been using your renderAnimation script for awhile and love it, but today I ran into a problem. The component says that all of the geometry has been added but then I get an error that there is “Nothing to render”. It seems to be file specific because if I open a new file I have no trouble. Any clues as to what might be wrong with my reject file?
January 23rd, 2011 at 8:13 pm
Hi Giulio-amazing work here…I’m trying to make your render animation script work, and running into issues with reflectance-is this an inherent limitation of the GH material component? I can edit it’s ‘shinyness’ value, but that doesn’t seem to allow me to vary for materials with high specular values (glass) to something slightly more matte (plastic). Any thoughts? Is there a workaround within your script? I know very little about coding / scripting in VB. Thanks!
January 23rd, 2011 at 11:41 pm
Hi Benjamin,
thank you. I’ve answered on the Grasshopper forum and also added the definition here. Have a nice Sunday,
– Giulio
January 23rd, 2011 at 11:43 pm
Hi Scott,
I’ve sent you an email. I’ll need a little more details, but maybe is it possible that a material already exists in the document?
Or maybe could it be that there are too many materials?
– Giulio
February 18th, 2011 at 12:36 am
Hello Giulio:
I’ve posted your site onto our website, and got your link through a mutual friend Judith Mussel. It is a pleasure to see what one can do and push the limits of Rhino and GH. I’ve been a long time user of Rhino, used Alias in the past and also Max user, along with other rendering engines, but really like what you’ve done with WeaverBird.
Hope to be in touch.
Kindly,
_WF