Getting levels from basically ALL CATEGORIES available in Revit with Python

I am struggling with something that should be simple… but has become a major inconvenience.

I need to read the level in which there is a wide range of categories (as seen below/ attached) but as there are many parameters responsible for the “level” I get a lot of errors.
I have tried to cast the parameters with if/elif/ else (as shown above) and with try/except. Besides being confusing I keep getting lots of nulls that, in Revit, are indeed signed at some level.

Has anyone dealt with this?
I need to use builtin parameters to ensure language-independent reading in Revit.

get levels.dyn (20.6 KB)

Hi @lcp9RMNF,

It is not a trivial task despite its apparent simplicity.
Use the Element Level node of the Genius Loci package.
It should work with all the categories/families that have a level.

3 Likes

It works

You are right @Alban_de_Chasteigner your node works fine :slight_smile:


I was still having many elements without the right level but when I divided them into nested and SuperComponents I realized it was not reading the level only for nested ones.

To filter nested x SuperComponents use the code below:

INPUTS

elements = UnwrapElement(IN[0])

CODE STARTS HERE

SUPERCOMPONENTS x SUBCOMPONENTS

super_comp, nested = ,

for e in elements:
if e.SuperComponent == None:
super_comp.append(e)

else:
	nested.append(e)

OUT = super_comp, nested

1 Like

Please could you share the code using the text code function to read it properly? Many thanks and interesting


##### INPUTS #####
#Preparing input from dynamo to revit
elements = UnwrapElement(IN[0])

#### CODE STARTS HERE ###
#### GET #####
super_comp, nested = [], []

for e in elements:
	if e.SuperComponent == None:
		super_comp.append(e)
	
	else:
		nested.append(e)




OUT = super_comp, nested

@RubenVivancos like this?