Inserting Elements in Specific Indices

Hello there,

I am pretty new to Dynamo and cannot get my head around something:

How can I insert elements in list at specific indices.

In the example below I have the Starting List 1…50, List of Indices (1,11,21) and List of elements (80,81,82) I want to insert at these indices.

I want 80 to go to index 1, 81 to index 11 and 82 at index 21 in a way lace the List of Indices to the List of Elements and insert them to the Starting List.

I want to keep the order so Index 0 from the List of Indices relates to Index 0 of the List of Elements I want to insert and so on (I do not want cross product) .

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Any suggestions would be great!

Regards

Kaloyan

 

Hi Kaloyan,

Just use “Insert” node. Good Luck!

 

Hi KULKUL,

Thanks for the fast reply, the Insert Node was my first resort but its not working the way I want it to work because it inserts the Full list of Elements instead of just the first Item.

Hi Kaloyan, How about this : ( dyn file -> insert-multiple)

multiple indices

Thanks Mostafa, this is great!

I was hoping I can get around it without having to type any code (as I am no good at it), but I guess its just not possible at the present moment.

I found out that List.ReplaceItemAtIndex from Clockwork does what I want but it Replaces Items… It’s going to be nice to have List.PlaceItemsAtIndex :smiley:

 

 

With a bit of list wrangling, this is fairly easy to do with the “LoopWhile” node:

the content of the loop function:

2016-04-05_16-42-59

You can later on replace the “Insert” node with whatever list action you need in your particular case.

Thank you very much Dimitar! Very informative :slight_smile: I tried using loop but without any success, and now I can see why :smiley: