Adding component to canvas by name?

The method you want to use is Grasshopper.Instances.ActiveCanvas.InstantiateNewObject

2022-12-26 03_00_52-Window
create GH component from name.gh (3.6 KB)

code:

  private void RunScript(string name, bool go)
  {
    if(wasgo & !go){
      id = Rhino.NodeInCode.Components.FindComponent(name).ComponentGuid;
      wasgo = false;
      GrasshopperDocument.ScheduleSolution(5, CreateComponent);
    }else{
      if(go)wasgo = true;
    }
  }
  // <Custom additional code> 
  bool wasgo;
  System.Guid id;
  private void CreateComponent(GH_Document doc){
    Grasshopper.Instances.ActiveCanvas.InstantiateNewObject(id, new System.Drawing.PointF(0, 0), true);
  }

Also:


create GH component from guid.gh (7.1 KB)

1 Like