Automatic parameter propagation by using C# components

Hello everyone,

I am trying to write a pipeline that reads in a XML file and automatically passes on parameters values to the respective components on the canvas. For this I created a C# component which takes a file name (with path), a tag name and a prefix as input. My C# component searches then the canvas for a components whichs nickname corresponds to the prefix + tag and fills in all the inputs that have the same nickname as one of the tags of the respective ChildNode in the xml. I then want to run this component, which just got new input, and ensure that its output is feed forward again.

However, the last two steps cause problems for me. The input parameters get filled in nicely, but the output is not computed and even in cases where I managed to compute it, it does not get fed forward downstream. After I call AddVolatileData() to fill in the input for every parameter I call CollectData() and ComputeData() on the respective cluster. To my understanding this should call the SolveInstance() method of the cluster and I already used this sometime in the past, where it worked nicely, but for some reason in this case it fails to generate any output.

Please find a small example attached. I would be very grateful about any help or hints on this problem.

private void RunScript(string File, string Part, object Prefix, ref object Found)
{

XmlDocument doc = new XmlDocument();
doc.Load(File);
List<string> allFound = new List<string>();
Grasshopper.Kernel.Special.GH_Cluster cluster = null;

foreach (IGH_DocumentObject obj in GrasshopperDocument.Objects)
{
  if(obj.NickName == Prefix + Part)
  {
    cluster = obj as Grasshopper.Kernel.Special.GH_Cluster;
    XmlNode part = doc.GetElementsByTagName(Part)[0];

    List<string> allXmlTags = new List<string>();
    foreach (XmlNode param in part.ChildNodes)
    {
      allXmlTags.Add(param.Name);
    }


    List<IGH_Param> allInputs = cluster.Params.Input;
    foreach (IGH_Param inputParam in allInputs)
    {
      string inputName = inputParam.NickName;
      int xmlIdx = allXmlTags.IndexOf(inputName);
      if (xmlIdx >= 0)
      {
        inputParam.RemoveAllSources();
        inputParam.ClearData();
        inputParam.AddVolatileData(new GH_Path(0), 0, part.ChildNodes[xmlIdx].InnerText);
        allFound.Add(Part + ' ' + inputName);
      }
    }
    cluster.CollectData();
    cluster.ComputeData();
  }
}

foreach (IGH_DocumentObject obj in GrasshopperDocument.Objects)
{
  Grasshopper.Kernel.GH_Component component = obj as Grasshopper.Kernel.GH_Component;
  if(component != null)
  {
    if(component.NickName != "ReadXML")
    {
      component.CollectData();
      component.ComputeData();
    }
  }
}
Found = allFound;

}

read_xml_file.gh (8.6 KB) parameters.xml (208 Bytes)