Insert Lists at Indices of a List


#1

Hey guys,

I have a problem I can t solve at the moment:

I want to convert the data type of various list and their values. Thus I deconstructed the list (list 1) and converted the datatype of the values they contain.

I used a list cycle to have some kind of dummy list where i can replace the indices, but I can t put the deconstrueced list back to its initial state.

I hope you understand the thing I m aiming for :slightly_smiling_face:

Please find attached my definition. Thanks in advance for any help!

180125_DataTypeConversion.dyn (21.8 KB)


#2

Insert can only insert one item into a single list at a time. Giving it multiple elements with multiple indices returns multiple lists.
image
In order to insert multiple indices into a single list you need to use python.

I think what you’re really trying to do is recreate your original list based on object types. You’re better off using a dictionary in this scenario. Your other option is to make a list with your indices [0,4,1,3,2] and another list with your object types (keeping the sublists intact). You should then be able to use GetItemAtIndex to get the particular sublist of object types from your list of indices.


#3

something like this?

180125_DataTypeConversion.dyn (24.6 KB)


#4

@erfajo

Thank`s a lot, this is the direct solution for my problem! I m starting to learn python, still a long way to go - this keeps me motivated.

@Nick_Boyts

Thank you too, as you mentioned dicitionaries - opens up new possibilities, I ll check it out!