Some custom Dynamo nodes need to handle inputs and outputs of variable nesting length. In python this can be done using var[]..[]
, but how to do it in C#?
To achieve this on the output of a node it is very easy as it’s done automatically when using the MultiReturn
attribute, see the docs.
On the inputs, instead, the secret is to use the [ArbitraryDimensionArrayImport] object item
attribute, see a sample node.
public static IList AddItemToEnd([ArbitraryDimensionArrayImport] object item, IList list)
{
return new ArrayList(list) //Clone original list
{
item //Add item to the end of cloned list.
};
}
Thanks to Peter for revealing this!