Grasshopper

algorithmic modeling for Rhino

Guide to creating custom grasshopper 0.6.X components

People might find this useful.  Please do let me know if you find any errors or omissions.

Best regards,

Ben Sitler

Note: on 2/4 at 13:00 I updated the manual to reflect the discussion on where to locate components on the Grasshopper ribbon.

Views: 19309

Attachments:

Replies to This Discussion

Thanks!!!
I've been looking for such things for ages...
I am having problems getting VS2008 Express to compile at all.
I get two errors after copy/paste:

Error 1 'Register_Boolean' is not a member of 'Grasshopper.Kernel.GH_Component.GH_InputParamManager' line 15

and...

Error 2 Overload resolution failed because no accessible 'GetData' can be called with these arguments: .... line 25

The errors are paraphrased. Does anybody have any idea?

Thank You,
Will
Without seeing what code caused the error and how it is structured, its difficult to say what is the issue. What does your input code look like? How are you setting up the get data on line 25?
luis
I am sorry, I should have been more specific.
I copy and pasted the code directly from Ben Sitler's tutorial.

line 15 : pManager.Register_Boolean("Execute", "E", "Execute?", False, False)

line 25 : If (Da.GetData(Of GH_Boolean)(0, Execute)) Then

I also would like to state that I have Windows XP 64, if that makes any difference and using GH 0.6.0059

Will
Hi Will,

when you type "pManager." (no quotes) in the VS editor, it should display a list of possible functions to choose from. Register_Boolean is not one of them. Register_BooleanParam is.


If (Da.GetData(Of GH_Boolean)(0, Execute)) Then

First, you don't actually need the (Of GH_Boolean) bit. This code is equivalent:

If (Da.GetData(0, Execute)) Then

Provided that Execute is of type GH_Boolean.

I'd also recommend using Boolean instead of GH_Boolean. When you ask for GH_Boolean, you'll get the actual instance of the data, which might be shared amongst any number of parameters. Thus any changes made to a GH_Boolean might have very unwelcome and unpredictable consequences. If you ask for a Boolean, you'll get a copy of the data which you are allowed to modify as much as you please. Thus:

Dim Execute As Boolean
If (DA.GetData(0, Execute)) Then
blah blah
End If


I'm in a bit of a tight spot right now so cannot provide proper support. Hopefully I'll have more time again next week.

--
David Rutten
david@mcneel.com
Turku, Finland
Thank you, David.
That made it work and has set me on my way.

Will
Hello Everyone,

thanks a lot Ben for the manual; it is very clear.
This is my first GH custom component, I come from a rhinoscript and C++ backgroud.
anyway I followed the steps to assemble the helloworld component using C# and i did manage to release the .dll file (.gha) and i put it in the grasshopper component folder

but when I started grasshopper i got this error message:

mscorlib: Could not load type 'helloWorld.HelloWorld' from assembly 'GHXcomponent00, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Does anyone know what went wrong?

Thanks a lot,
Hi Georgia,

which version of Grasshopper are you using?
If it's a 0.7.x version, you can download the latest SDK documentation using the _GrasshopperGetSDKDocumentation Rhino command. It contains updated instruction on how to setup components.

The exception above (TypeLoadException) can be due to many factors, including a reference to a third .dll that is not found. This exception normally has an InnerException that contains some additional information...

Is the constructor parameterless and public?
Do you reference other types in the constructor?

- Giulio
________________
giulio@mcneel.com
McNeel Europe, Turin, Italy

Ben, Thanks.

 

However, I'm getting a few problems (I'm usinng Rhino4, Grasshopper 0.8.0051 and VS Express).



The first problem is in your VB example, line: 

pManager.Register_Boolean(...)

but I seem to have fixed by using pManager.Register_BooleanParam

 

The second problem is in line: Da.GetData(...). The error is No accessible 'GetData' can be called with these arguments. I think it's not recognising the Exexute type boolean.

 

 

Actually, reading on David's post, fixes my second query...

Once the component is written and working how do you distribute it ?

Hi Sivam,

 

there is no real centralised place for this. You can put it on Food4Rhino or provide a download on a personal website/blog.

 

GHA's are loaded by end-users typically by drag+dropping them onto Grasshopper. This will copy the gha file into the components folder. 

 

You can also put the gha file manually into the components folder. The folder should be at AppData\Roaming\Grasshopper\Libraries, but it differs on different versions of Windows. Find the Components folder via the File->Special Folders->Components Folder menu item.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

 

 

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service