logo

teocomi


Sometimes I write about code & tech in the AEC industry.
Co-founder of Speckle.
Formerly Arup, Foster+Partners, WeWork, CASE Inc.


Handle Variable Input List Length Nesting In Custom Dynamo Nodes

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!

comments powered by Disqus