Has anyone found a good method for handling various input types in a custom node? I’m trying to find a python or OOTB solution that allows me to take a variable input (flat list, nested list, single item, etc) and to turn it into the same type of list structure. I tried using flatten and list.join, but that doesn’t work for single items that are not part of a list yet. List.create causes problems for already nested lists. Thoughts?

I essentially just need a flat list. The input could be a single item (taken from “Select Model Element” node) a nested list, or a flat list. The goal is to make the node more user-friendly so that one doesn’t have to know the exact nesting required.

Here’s a basic example with a python node. The below is two identical scripts, the first one has a defined input as a single object, the second one is left undefined. This way you can skip doing any checks in the python node but as I said earlier, performance will suffer on large data sets(compared to zero touch or built-in nodes) because the python code will have to be re-evaluated for each item:

Dimitar, after reading through your response, I saw that you actually had an answer for the question. I thought that the input nodes only allowed one to structure something of a certain type (point, line, integer) which is why I thought your response would not work for me, but after reading through your response and also Colin McCrone’s post on the blog (http://dynamobim.org/what-does-var-mean/) I see that I can use var[] as the input, which will automatically flatten or create a list to match a flat list structure for any input type. Works great, thanks!

Hello, this thread is very helpful. But can anyone suggest how to do the same in C#?
If I use object it will just recuse the input at the item level, if I use List<object> instead it will ignore nested lists.