Hi there!
TL;DR: how can I avoid C# script components automatically assigning the ref
values to the outputs?
I am writing a C# script component where I want to be able to account for changes in the amount of outputs (plus and minus icons on components), so I need a way to assign outputs programmatically. I am using Output.AddVolatileData()
, such as:
private void RunScript(object x, object y, ref object A, ref object B)
{
for (int i = 0; i < Component.Params.Output.Count; i++) {
Component.Params.Output[i].AddVolatileData(new GH_Path(0), 0, "This is output #" + i);
Component.Params.Output[i].AddVolatileData(new GH_Path(1), 0, "This is output #" + i);
}
}
But it turns out that the first element of path 0
always get overriden with a null
element:
I am assuming this is because the component takes the unassigned A
and B
refs and places them automatically in the output datatrees. This is easy to see because it doesn’t happen in the out
output, if I AddVolatileData
to other branches, or if I manually assign values to the ref
outputs before the AddVolatileData
call.
So, my question is, how can this behavior be overridden, so that I can assign values to all outputs programmatically, without having the first element always be null
?
Thanks!