algorithmic modeling for Rhino
I feel like I'm missing something obvious. I'm reading through the SDK documentation on how to create a custom Grasshopper component. I've created the class library, inherited from GH_Component, built the dll, and renamed it to a GHA file.
But how do I tell grasshopper to load my GHA file?
drag and drop the gha file onto your grasshopper window. It should install on it's own.
This won't work for updates yet, I don't think. But it does work for initial install.
It appears that dragging in the GHA file just copies the files into the following user folder:
<user folder>\Application Data\Grasshopper\Libraries
So I assume that Grasshopper just searches these folders for GHA files to load when it starts up?
there are three ways to do this:
1) If you're called David Rutten and about 1.95m high you're allowed to put the GHA file in <Program Files>\Rhinoceros 4.0\Plug-ins\Grasshopper\Components\
2) If you're a user who wants to install a GHA file written by someone else then you should put the file in <user folder>\Application Data\Grasshopper\Libraries You can either do so manually or drag+drop the gha file into Grasshopper and a copy of it will be placed in that folder (as you noted)
3) If you're a developer who wants to compile and test your GHA assembly, I recommend you add an additional GHA folder path to the Grasshopper loading sequence. You can do this via the _GrasshopperDeveloperSettings command. Any GHA file in any of the folders listed there will be loaded.
Note that if you compile the GHA files yourself, you'll end up with two different ones if you use the default Visual Studio setup. Namely one file in bin\Debug\ and another in bin\Release\, depending on the build flavour you pick at any given time. This is annoying. Really annoying.
I highly recommend you change the default behaviour of VS to always put the compiled file into just bin\ This will prevent Grasshopper loader conflicts.
ok 4) If you've written an installer for your GHA and insist on putting it in a custom folder (maybe next to an RHP file that belongs to the same project) then you can change the grasshopper settings xml file from within your installer. This is basically the same as adding an extra search path via the _GrasshopperDeveloperSettings command, but it doesn't involve starting Rhino.
I would like to install a GH plug-in that relies on a C++ dll. When placed in the 'Components'-folder however Windows does not find the dll.
Would it make sense that Grasshopper adds the path to the 'Components'-folder to the Windows 'Path' environment variable so that C++ dlls are automatically found there?
do not put your files in the Components folder, that folder gets nuked when a Grasshopper update is installed. Either put it in %appdata%\Grasshopper\Libraries\ or use an RHI installer* or use a custom installer and put a *.ghlink file in the %appdata%\Grasshopper\Libraries folder.
We will try and load .NET dlls from all sensible locations, but I don't think we handle C++ dlls at this point. I sincerely doubt we'll be messing with environment variables (there's all sorts of user privilege problems there I think). If the dll you need is next to your GHA file, you should be able to load it yourself from a GH_AssemblyPriority derived class.
* I'm not entirely sure whether this will work yet for non RHP installs, but this will definitely be the official recommended method soon
Maybe this video will help: http://www.grasshopper3d.com/profiles/blogs/building-a-component-with
(from 7:30 to about 8:30)
McNeel Europe, Barcelona
I was wondering if you could repost this link? This link navigates me to http://www.grasshopper3d.com/profiles/blog/list?q=building+component+. I'm not sure if it exists anymore, but it might help me finally understand all the steps in setting up a custom component.