Hi all, I do not understand why the “.append()” do not work
When I run the code below, I only get 1 item in the list “list_Family_Names”
Can someone help me to understand why??? O.O
thanks!
# filtering elements in currentDB
get__All_CommDevices_Elements = FilteredElementCollector(docRevit).OfCategory(BuiltInCategory.OST_CommunicationDevices).WhereElementIsElementType().ToElements()
for el in get__All_CommDevices_Elements:
element_Family_Name = el.FamilyName
list_Family_Names = []
list_Family_Names.append(element_Family_Name)
OUT = list_Family_Names
move list_Family_Names = outside the loop. Otherwise every iteration you recreate your list over and over again
1 Like
And you miss an indent before list_Family_Names.append.
docRevit = DocumentManager.Instance.CurrentDBDocument
list_Family_Names = []
# filtering elements in currentDB
get__All_CommDevices_Elements = FilteredElementCollector(docRevit).OfCategory(BuiltInCategory.OST_CommunicationDevices).WhereElementIsElementType().ToElements()
for el in get__All_CommDevices_Elements:
element_Family_Name = el.FamilyName
list_Family_Names.append(element_Family_Name)
OUT = list_Family_Names
1 Like