Python - Get Element Family Name then apply a filter

See below:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

category = UnwrapElement(IN[0])
elements = FilteredElementCollector(doc, doc.ActiveView.Id)\
		.OfCategoryId(category.Id)\
		.WhereElementIsNotElementType()

filtered = []
for e in elements:
	type_id = e.GetTypeId()
	element_type = doc.GetElement(type_id)
	family = element_type.Family
	name = family.Name
	if '???' not in name:
		filtered.append(e)
	
OUT = filtered

What you are assigning to the ‘familyname’ parameter is actually just the FamilySymbol. Get the Family from the FamilySymbol and then get the Name from the Family (this is inherited from the Element class).

I should also note that the above code expects a single Category being provided to input IN[0].

2 Likes