Flatten multi-dimensional list

#1

Hello, I have a multi-dimensional list, which contain multi number of lists in level 2 and 3 and normally single item list in level 1 but occasionally it got 2 items in some of the level 1 list. I want to remove all second items in level 1 lists but keeping the multi-dimensional list structure. I have try “List.First Item”, “List.Take Items”, “List.Normalize Depth”, “List.Remove Item At Index”, “List.Filter by Bool Mask” and "List.Flatten. But they don’t work in the way I want. May I have any suggestion on how my task could be done?

0 Likes

#2

Can’t test it out right now but have you tried List.FirstItem with @@L1 or @@L2? The double @ is when you have Keep List Structure checked. To enable this in the current Dynamo versions, you have to check that option, save the graph, close the graph, and then reopen. It should then be blue with @@L1 or @@L2.

0 Likes

#3

Hello Kenny,
Thank you for your advice!
I’m using Dynamo version 2.0.2 and I can’t find the double @ option. Is it a new option in version 2.1?

0 Likes

#4

The double @ option started in 1.3 I believe (maybe earlier, I can’t remember) and it is in 2.x+. You can access it by clicking the arrow next to the list input (where you would go to enable levels) and it is the second option in the drop down menu, right below enable levels. It should read Keep List Structure.

0 Likes

#5

Oh! Thank you!

0 Likes

#6

Thank you very much!
Both “Take Items” and “First Item” work. But with a little bit different. I need to check which is better for my case.

1 Like