How to assign data .Params.lnput[i] to Params.Output[i]?

Hello again @Mahdiyar , how to assign data Component.Params.Input[i] to Component. Params.Output[i]?
Continue to discussion

This c# code for separation dataList by key in branch of tree
This should be work for any input insert parameter.input similar sorList component


sort key.gh (10.9 KB)

  private void RunScript(List<string> key, List<System.Object> a, List<System.Object> b, ref object A, ref object B)
  {
    _key = key;
  }
  // <Custom additional code> 
List<string> _key;
public static IGH_Structure SortKey(List<string> key, List<IGH_Goo> data)
{
  var k = key.Union(key).Distinct().ToList();
  k.Sort();
  var s = new GH_Structure<IGH_Goo>();
  for(var i = 0; i < k.Count; i++)
    for(var j = 0; j < key.Count; j++)
      if(key[j] == k[i]) s.Append(data[j], new GH_Path(i));
  return s;
}
public override void AfterRunScript()
{
  for (var i = 0; i < Component.Params.Input.Count; i++)
  {
    Component.Params.Output[i].ClearData();
    Component.Params.Output[i].AddVolatileDataTree(SortKey(_key, Component.Params.Input[i].VolatileData.AllData(false).ToList()));
  }
}

Sort.gh (10.7 KB)

2 Likes