Packaging a grasshopper cluster as a Rhino Command

Hi all,

I seem to remember a developer doc, code example, or forum entry that shows how to invoke a grasshopper network during the operation of an ordinary Rhino plugin - for instance, to compute some intermediate geometry. What I’m looking for does not seem to be at the developer docs or code examples. I searched the forum and found out that the question has at least been asked before:

Invoke Grasshopper snippets with a Rhino Command - Grasshopper - McNeel Forum

I could not find an answer. Apart from my own laziness being a contributing factor, the reason is little funny: The opposite question has been asked much more frequently in the last 8 or so years, and this skews the search!

Does anyone remember what I’m talking about?

Hi Max -

You can use the Script Compiler tool that ships with Rhino 7 to turn Grasshopper graphs into a Rhino plug-in. For this to work, you need to set up your graph so that it can be run with the Rhino GrasshopperPlayer command.
-wim

1 Like

@wim,

I am glad to hear we can simplify this solution as soon as we upgrade to V7! That means I can retire all our V6 workarounds by fall! :partying_face::raised_hands::birthday: :cake::balloon::tada: :gift:

Unfortunately I have to build this feature against V6! :skull_and_crossbones:

–Max
(TeakOmatic)

Possible solution: Use a Rhino.Commands.Command object to control the GH kernel; Cache the kernel to accelerate the command.

  1. On the first call:

    • Init the GH kernel, load the network
    • Cache the kernel in the doc’s User Objects, to avoid the Kernel init on subsequent command calls
  2. Subsequently:

    • Get the cached GH kernel
    • Collect the user input
    • pass input to the GH kernel
    • tell the GHkernel to bake the result to RHobjs
    • Send the RHobjs to the RhinoDoc

@DavidRutten do I recall that you wrote a guide on essentially the same steps? If I am not mistaken, can you help me locate that note?

Other questions:

  1. Does my solution sketch omit any steps?
  2. Is the current doc’s User Objects the right place to persist the GH kernel?

Thanks David, Wim!

– Max
(Teakomatic)

1 Like