Zerotouch list flattening

Hi guys,

I’ve got yet another zerotouch question: how can I first flatten my incoming data and then execute my code for all data at once?

I worked out I could use DSCore.List.Flatten(); to flatten some data, but I don’t know how to implement it. I think I need to flatten my data before executing the code?

Any thoughts?

Thanks again! :smiley:

You could simply just use C#/linq to do this…

Also, could you not rely on the OOTB lacing that the nodes do instead of hard coding the flatten? Or is this not working? The problem with flattening is that the OUT data will not be in the same structure as the data that went in… It will be a flat list.

1 Like

Hi Daniel! Thanks for the reply!

The goal is to always flatten all outgoing data, because I have no need for those list structures. Even worse: because I use an external API I would that called multiple times, which leads to undesirable behavior (more time consumed, improper functionality, etc.).

What seems to happen (correct me if I’m wrong) is that for each nested list, my code runs the full method:

    //Nested list enters here:
    public static List<object> TestNode(List<Autodesk.DesignScript.Geometry.Point> DynamoPointList)
    {
        //do some code
        List<object> Return_objects = new List<object>();
        return Return_objects;
        //Now only the nested list is returned and the method is started over again
    }

So I get this behavior if I do not flatten the list manually (either before or after the ‘Elements.Node’ Dynamonode:

Ah, you only have one output for all inputs (regardless of data structure)? in this case, just use the link I sent earlier, this flattens a list (your input list) and you can then operate on the whole of that and return the result.

1 Like

Hi Daniel,

Cool! So that will work for a list in a list.

But what about a list in a list in a list :laughing:



I could code up until a few levels deep but that would be

1 Like

Totally missed your post way before mine saying the same thing!

Great minds think alike :wink:
That solution was right though.

Thanks guys!

Glad to hear it’s working, please mark a solution for the post.

Awesome, glad you got it working! Full steam ahead and good luck on the nodes! :wink: