Hello Rhino Community
I am trying to access the grasshopper panel by writing a c# script. in the script below i am able to open the grasshopper file and access the IGH_DocumentObject objects in it.
I need help in knowing the best way to find a specific panel and also changing its value
public class GH_ABC
{
public static Result RunGHDef()
{
Object grasshopper = RhinoApp.GetPlugInObject("Grasshopper");
if (grasshopper == null)
return Result.Failure;
grasshopper.GetType().GetMethod("DisableSolver").Invoke(grasshopper, null);
string filePath = @"C:\Project_Folder\fksm\rhino_grasshopper\grasshopper_template";
grasshopper.GetType().GetMethod("OpenDocument").Invoke(grasshopper, new object[] { filePath });
grasshopper.GetType().GetMethod("ShowEditor").Invoke(grasshopper, null);
return Result.Success;
}
GH_Document ghDoc = Grasshopper.Instances.ActiveCanvas.Document;
private static IGH_DocumentObject FindPanelComponentByNickname(GH_Document ghDoc, string nickname)
{
foreach (IGH_ActiveObject obj in ghDoc.ActiveObjects())
{
if (obj.NickName == "Project ID")
{
// code here to change the value of the panel with nickname "Project ID"
return obj;
}
}
return null;
}
}