VS C# Reading another components data in the base.read/base.write

Hi all,

I have a component to update panels to default values if needed.
The GUIDs of the target panels are saved in my component through this method.

writer.SetGuid("targetPanelComponentGuid", targetPanelComponentGuid);

I’m working on a function to update all of my panels in the entire canvas. But how should I approach it?
I would imagine something like this;

ghDocument = OnPingDocument();
List<IGH_ActiveObject> allActiveObjects = ghDocument.ActiveObjects();

foreach (IGH_ActiveObject activeObject in allActiveObjects)
{
    if (activeObject.ComponentGuid.ToString() == "e40ccee5-232e-44a0-9624-fb0ea34a833a") //being this type of object
        {[DefaultPanel_VS.zip|attachment](upload://4fGLxmlvOLeVQlAXlYh2h6YhuiS.zip) (3.7 MB) 
            var panelGuid = activeObject.Reader["targetPanelComponentGuid"]; //<-- bugger

            UpdatePanel(panelGuid); // some treatment of the newly retrieved Guid.
         }
}

Screen below probably explains it better.
Each component is working well in my setup - however I would like to have a function in the component to activate all the other components also.
So either calling a class/method locally on the other components - OR - get the guids of their connected panels (that i now have in the write/read)

private void RunScript(string x)
{
  var inputPanel = Component.Params.Input[0].Sources[0];
  foreach(var obj in Component.OnPingDocument().Objects)
  {
    if(obj is GH_Panel)
    {
    if(obj == inputPanel) continue;
    //prevent input panel from updating
    
    GH_Panel panel = (GH_Panel) obj;
    panel.SetUserText(x);
    }
  }
}

GH_Panel.gh (6.1 KB)

It’s a bit more complex than as such;

I want to:

  1. get the GUIDS of all panels connected to each of my “updater” components.
    1a) this is already done internally in each “updater” component. but how do i access that globally…
  2. Update all the panels in the updater.output to match the updater.input.
    It’s important to do without wires, because if a panel is connected in its input then its not editable on doubleclick.

private void OnClick(object sender, EventArgs e)
{
    var source = OnPingDocument().FindObject(sourcePanelComponentGuid, true);
    var target = OnPingDocument().FindObject(targetPanelComponentGuid, true);
    if(source is GH_Panel s && target is GH_Panel t)
    {
        t.SetUserText(s.UserText);
    }
}

DefualtPanel.zip (38.5 KB)
P.S: The link in your post seems to be broken, That is why I worked on the older version of your code.

Hi Mahdiyar,

This is sort of what I have in the project now, but im looking for a way to have

source 1 ---- defaultpanel1 ---- target1
source 2 ----- defaultpanel2 ---- target 2

source N — defaultpanel N — source N.

Each defaultPanel can only have 1 target and 1 source.
Is there a way I can activate ALL of the defaultPanels in one go?

Ideally each panel has two functions:
UpdateConnectedPanel <-- this is what you sketched and I have in the script now
UpdateALLpanels <— this is what I’m looking for :slight_smile:

Hoping it makes more sense and sorry if I’m bad at explianing!

Btw it’s hosted here, hope link works
DefaultPanel-master.zip (3.6 MB)