How to create a button in Rhino that launches a specific Human UI/GH script

I would prefer this to happen such that the user never sees Grasshopper? I would click the button in Rhino -> perform the operations in the UI -> Bake -> then close. Grasshopper is hidden with no opportunity for modification of the GH.


There is no simple and straightforward way to do this, but a collection of tricks make it possible. I think @marcsyp is the world expert on this - he may have some suggestions. Here’s the basic approach:

  1. Associate a button with a command macro that launches your grasshopper file. something like this:
    -_Grasshopper _Document _Open "C:/"
  2. to launch Human UI, just leave the “Launch Window” component’s run input set to true - and set the window to be “Child of Rhino” so it remains while grasshopper is minimized
  3. use a c# script inside your grasshopper script to minimize the GH window (only way I know of to hide GH window without making it inactive) Grasshopper.Instances.DocumentEditor.WindowState = FormWindowState.Minimized;
  4. if you want to close grasshopper after you’re done, you can trigger something like the following with c# script with a boolean input called “close”:
    if(close) Grasshopper.Instances.DocumentEditor.ScriptAccess_CloseAllDocuments();

like i said - not ideal. but possible to get a reasonable approximation of what you’re after.


This sounds like what I am after. Many thanks Andrew.

I did not know you could combine command macro and c# script under 1 button. I have familiarity with Python but no c# experience. Could you provide an example of what that full button would contain please?

It is a great privilege to have access to the knowledge and experience of those behind the tools. The Rhino community never ceases to amaze me.


Unfortunately that’s not what I’m saying; in the above points the C# scripts are executed in grasshopper, and the macro is just to launch a grasshopper script. I don’t believe there’s a way to trigger c# scripts with a button short of writing a full rhino plugin. The command macro for the button is merely what I have written:
-_Grasshopper _Document _Open "C:/"

and the grasshopper script contains c# scripts which execute on launch or when triggered by the user.

Create a button and execute a python file that can open GH, hide the window and assign data to a component. You can see the reference commands for this here: RhinoScript's Grasshopper Methods List?
All these commands are part of the Rhinoscriptsyntax, so will work as rs.AssignDataToParameters.

All you need to do is set up your GH file, find out the id for the GH toggle button that will switch on the window (if needed) and then hide the window.