Filter and flatten nested list of lists preserving indices

revit
dynamo

#1

I have a nested list of lists which shows rooms and which floors are inside them. However I can’t seem to work out how to convert that list so that it only shows floors whilst preserving the indices (images below should explain more):

This demonstrates the intended purpose/workflow thereafter:


#2

like this?

however, feeding an empty list will give an error.


#3

Hi erfajo, cheers for the input. As you highlighted the index method fails when trying to preserve null fields:


#4

then try this… however, you need to do something with the empty list, since that index will be removed…


#5


#6

or maybe like this


#7

Yes, I reckon this should get me there provided I can use the ‘empty’ entries in the original list as a Boolean mask on the list of all rooms. That way the indices for my rooms and floors will match up. Cheers

Left the office now, will have to try it out later.