generative modeling for Rhino
I'm new to Grasshopper (and to .net in general - coming from java background), and have a question regarding development.
Can I "drive" Grasshopper from another plugin inside Rhino? I want to create a custom GUI to manipulate existing nodes in a grasshopper file. My intention is to control user input instead of free access to the grasshopper nodes, but have grasshopper do the heavy lifting in regards to geometry creation? Reading through the SDK it seems like this is possible, and I suspect I'm just having a newbie moment.... Any direction and insight is greatly appreciated.
tricky, but possible. There's two approaches that you can take:
1) Use Reflection to invoke methods on the Grasshopper assembly. This is made a lot easier with the dynamic keyword in C# 4.0. The main problem here will be making sure you hook into the Grasshopper already loaded in Rhino rather than loading the dll on demand via your plug-in.
2) Reference Grasshopper in your own assembly and call it's methods directly. This latter approach means you almost certainly have to write your tool as a plug-in to Grasshopper.
I've never tried either approach so I cannot give you practical advice, except to say you'll have something up and running quicker with approach #2.
Thanks for the leads. I'm going to look into those methods. I had a thought for another option last night:
Create a plugin for Rhino that is simply a GUI over a dataset attached to a Rhino object and write VB or C# nodes in Grasshopper to query that data for input values (I don't need heavy interaction, just the ability to set input data for the grasshopper nodes). I'm worried about communication issues though - don't know if there are any huge pitfalls with this method (event triggers and data access conflicts worry me).
Question: How does the grasshopper solver get triggered?
I'm assuming this is for Rhino 5, and may not work in V4.
I haven't tried this myself yet, but you should be able to add a reference to grasshopper.dll (with copy local set to false). In your plug-in command class, call Rhino.PlugIns.PlugIn.LoadPlugIn with the id of the grasshopper plug-in when the command is first run. This is done to ensure that grasshopper is actually loaded and initialized correctly before any functions on the grasshopper dll are called. After that, you should be able to directly call functions on the grasshopper DLL.
This also assumes that grasshopper is installed for your plug-in to work.
I'll look into that option - it sounds pretty straightforward.