Replace at index using levels

Trying to replace some items using the OOTB List.ReplaceItemAtIndex and levels… but no luck

I also found this, but it is before levels were introduced so hope to find a newer way.


ps: copy pasting in case anyone wants to try


I often struggle with levels on ReplaceItemAtIndex and I don’t know a solution to your case using that node, but here’s an alternative that I find easier to understand (but it’s probably less efficient in the number of nodes it uses).

Once you have the indices you wish, you can use List.SetDifference to get the other indices and then get the relevant items from each list, stitch them back together along with the indices and then use List.SortByKey to reorder them back to the initial order.

I’ve done this in Dynamo 2, but the same logic applies in 1.3 (which I assume you’re using given the curly brackets around your lists)

Hope this helps,

42023.dyn (24.9 KB)


is this what you are looking for Thomas?

Dynamo Post 21-10-2019 Thomas Corrie.dyn (10.5 KB)

Hi @Daan, that works for the specific scenario but you are manually inputting the indices and each subsequent replacement requires the index and another List.ReplaceItemAtIndex node. Whereas the solution I suggested could scale to numerous instances without adding further nodes.

I think Orchid has a node that will do this but ootb nodes won’t replace multiple indices in the same instance of a list. Python is a great option here.

Hi @simoneavellini

You can replace it by using Imperative blocks: