EDIT You will need to open the family to access the Part Type FamilyParameter
You can use a FilteredElementCollector and a ParameterFilterRuleFactory to get all elements where the parameter exists and has a value - like this
After a bit of digging… The part type information is located in the family file (.rfa) Family Class - so you will have to open for each family type you want to access (you could open the family for each instance but that would use more time and computer resources). Here is an example to get the part types for Air Terminals
import clr
import sys
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
def get_PartTypeValue(family):
with doc.EditFamily(family) as famdoc:
parttypevalue = famdoc.OwnerFamily.get_Parameter(
BuiltInParameter.FAMILY_CONTENT_PART_TYPE
).AsValueString()
famdoc.Close(False) # Close without saving
return parttypevalue
doc = DocumentManager.Instance.CurrentDBDocument
fec = FilteredElementCollector(doc)
families = fec.OfClass(Family).ToElements()
terminals = [f for f in families if f.FamilyCategory.Name == "Air Terminals"]
OUT = [get_PartTypeValue(t) for t in terminals]
Thanks, good examples. The error was just because mistake by using the builtin parameter that appear in the element properties of the project environment but not the builtin parameter of a family which is FAMILY_CONTENT_PART_TYPE, I checked wrong by looking in the Revit API website BuiltInParameter Enumeration.
I resolved it as well by searching a parameter by name “Part Type” but prefer to use built in parameter.