Transferring An Item Into The Correct Index

I’m curious about how one would go about creating blank indices in order to prevent information in one index falling into the one before it.

A quick example:

I need to force all elements called Edgeform to be in idex 2, otherwise they won’t align properly in a schedule. Likewise, I need to force all elements named Shoring into index 0, and all elements named Bulkhead into item 1.

I’ve attached a copy of my file which should help illuminate my problem if my explanation is lacking.

Model elements and material paint to excel-walls 10 list combining and schedule sorting.dyn (43.5 KB)

*I am a dynamo noob so please burn me at the stake for my stupidity

I’ve come across this before and struggled with it for a bit so I feel your frustration. I’m positive that python has a better solution for this, but I don’t know python, so here is my out of the box solution:

Flatten node on the overall list.
Unique Items out of the flatten node.
Index of off the original list with the results of the flatten node (watch the lacing - should be cross product).
Transpose the results and separate your base level lists with a “List.GetItemAtIndex” node until you have 3 separate lists of indices.

You could just use a string to pull the data you want but that’s assuming you never have a “EST - Shoring 2017” value coming sometime next year or want to have to rebuild your graph at a later date. Either way, you should now have a zero based index for each instance of each value in the list, with a -1 for each list which doesn’t have an item in it.

Fed the source list and the resulting list of indices into a List.GetItemAtIndex node with a lacing longest setting and you will pull every instance of each item from the source list, and a null value for each -1.

Join your lists transpose and you now have equal length lists sorted by unique values and a null value for each item not present at the same location and depth relative to the base list.

If you want the items in a different order on the final output, shuffle the indices in the final List.GetItemAtIndex node.

The top branch here replaces some nodes with code blocks to make the flow of data more apparent - I hate spaghetti.

1 Like