List Creation

Hi all,

I’m checking which rooms (central files) the elements (linked files) are located at. I need to assign the room name to the respective elements in the linked files. Currently I have two lists, the rooms and the elements in the rooms. I’m thinking about creating a list shown in the red box but I’m not sure how to create it. Appreciate if someone can help me with that. Thank you!

Can’t test it at the moment but something like this might work?

roomList = IN[0]
eleList = IN[1]

eleInRoom = [[],[]]
for i in range(len(eleList)):
    eleInRoom[0].append([])
    eleInRoom[1].append([])
    for j in range(len(eleList)):
        eleInRoom[0][i].append(roomList[i])
        eleInRoom[1][i].append(eleList[i][j])

OUT = eleInRoom
1 Like

HI ,
you can get Count of the element list using Count Node with L2, Then List.Cycle the Rooms With Amount of Count Result

2 Likes

@kennyb6 Sorry I’m new to dynamo and not really familiar with the script but I will try it again when I’m familiar with it. Thanks for your help!!! :slight_smile:

@khuzaimah.ElecEng It works! Thank you so much!!! :slight_smile:

No problem. For future reference, that is a python script. Just make a python node, double click it and paste it under where it says to put inputs (delete the data… variable first).