Calling a Grasshopper Cluster in a Command

Hi everyone,

I’m trying to find a way to run Grasshopper Definitions as a script.

Here is an example GH Definition, I would like to automate:

The goal would be to run the Rhino Command “CreateManyCircles”
Have the user be prompted for one or several Curves and then have 13 circles be backed / added to the document


protected override Result RunCommand(RhinoDoc doc, RunMode mode)
//Cluster Filepath
string path = @“c:\test.ghcluster”;

        if (!System.IO.File.Exists(path))
            return Result.Cancel;

        //Read GH Cluster at file location c:\test.ghcluster
        //Find out which clusters inputs are required

        //Foreach Input in Cluster: Promt the User in Rhino
        //Varify Input

        //Call Grasshopper Cluster File and hand over input as  variables to GH Definition    
        //Get Geometry Objects back from the Grasshopper Clusters               

        //Add the Objects to the document            

        return Result.Success;

Even though I created custom Grasshopper Components, I still can’t really wrap my head around the GH Code Architecture in depth.
Could someone provide an example of the bulletpoints above.


P.S. Added the Grasshopper definition (as gh File not as ghcluster file, because of the upload filter) (4.3 KB)

I guess the more general Questions in this context would be:

  • Is it possible to run Grasshopper “in the background” and use it without a user interface?
  • How do I connect to a clusterFile using c#?
  • How do I tell a cluster File to “run”?


Possible using rhino.compute