Read panel data in C# script [closed]

I am trying to write values to a panel and do some operation and read the output from a panel using c# script. some how I managed to write data to panel but I am unable to read the output back.

private void RunScript(string nickName)
{
  foreach(var obj in GrasshopperDocument.Objects)
  {
    if(!(obj is GH_Panel)) continue;
    var panel = obj as GH_Panel;
    if(panel.NickName != nickName) continue;
    foreach(var data in panel.VolatileData.AllData(false))
      Print(data.ToString());
  }
}

Panel.gh (4.2 KB)

2 Likes

Panels, like parameters, can have internalized data.

The text string “Double click to edit panel content…” is just some internalized data.
When you connect a source to the panel, that new data will just have priority, but the actual user data is not erased.

The same way you could have a geometry parameter with internalized data but that data is “hidden” if you connect a source to the parameter.

volatile data

 private void RunScript(object x, object y, ref object A, ref object B)
  {
    List<Grasshopper.Kernel.IGH_ActiveObject> objs = GrasshopperDocument.ActiveObjects();
    foreach(IGH_ActiveObject obj in objs){
      if(obj is Grasshopper.Kernel.Special.GH_Panel){
        Grasshopper.Kernel.Special.GH_Panel panel = obj as Grasshopper.Kernel.Special.GH_Panel;
        if(panel.NickName == "asd"){
          A = panel.UserText;
          B = panel.VolatileData.AllData(false);
        }
      }
    }
  }
2 Likes

@Mahdiyar @maje90 thank you so much it works :slight_smile: :man_dancing: