Python get Name of the Family from Elements


#1

Hi all,
I am trying to execute some code withe the python script node, I am a HUGE newbie at the moment, but I’m working on it :wink:

At the moment I am stuck at finding the name of the family from a list of elements.
If you can help me with that, it would be much appreciated.

This is the code so far:

#Collecting instances from the model with the Communication Device category
allCommDev = []
cl = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_CommunicationDevices).WhereElementIsNotElementType()
allCommDev = cl.ToElements()

Obviously I’ve tried a lot of different pieces of codes (that I am not writing because are almost blasphemy), but ended nowhere :confused:

thanks in advance


#2

You need to loop through your list :slight_smile:


#3

thanks @CVestesen,
I know it would require a loop iteration but I don’t know the syntax to do that, if you have a reference documentation it would be helpful too :slight_smile:


#4


#5

And if you want the family name, you need to change the CollectorFilter to WhereElementIsElementType() and then get the property from ElementType “FamilyName”. On the above code I used the property from the Element class to collect the Element.Name :slight_smile:


#6

thanks @CVestesen :slight_smile: