List logic replace by condition

Dear reader,

While reading the levels from elements form a linked file (using archilab package), the levels are not physically in the current Revit project to place objects on using dynamo. By copying these levels from the linked file into the current Revit document this problem is solved and it is now possible to place objects on these levels.
However these levels are not the same in id number. So when reading the host levels of objects in the linked file this list does not correspond with the levels in the current Revit document.

In conclusion my question is ‘how do i replace objects in a list based on if there names are the same?’

In the screenshot below you’ll see the levels read from the objects in the linked file and the copied levels in the current Revit model. You can see the id numbers are different. On the right I have written the result I try to achieve.

I tried ‘replace by condition’ and a number of other list sorting nodes, but I can’t seem to figure it out. Can someone help me with this list logic?

Kind regards,

Im not on pc right now. But i think you could with indices of or list Unique indices if you use it on the name.

Or group by key and take every first item of a list.

Ill get back in an hour or so when im at pc

It currently doest work because they are all Unique element ids. Try using the name if thats what makes them the same :slight_smile:

As @Schasfoortyoeri said, your best bet is taking the names and finding the levels with the same name, as long as all levels have the same name across projects. This is one example of how to do it:

*Note the cross-lacing on the == node and list@L2 on the indexof node.

1 Like

Thanks a bunch, Much appreciated!

Could also use dictionaries: