How to get all family types of a family in python?

How to get all family types of a family in project environment with python code? I tried GetValidTypes Method but I get Empty List as result, and obviously the family that I target has types in the project environment.

This should do what you want: GetFamilySymbolIds Method

Well that and a line along the lines of familyTypes = [doc.GetElement(i) for i in symbols]

3 Likes

I resolved like that surprisingly:

    # Find the FamilySymbol that matches the family name
    all_family_symbols = FilteredElementCollector(doc).OfClass(FamilySymbol).ToElements()
    family_symbols = UnwrapElement([sym for sym in all_family_symbols if hasattr(sym, 'Family') and sym.Family.Name.lower() == family_name_part.lower()])

That’ll be slower, but if it works it’s a victory!

Definitely recommend Jacob’s approach as it will scale better given your proposed alternative goes through all family types. Both technically work, but scalability is pretty handy when deploying solutions in models which might be potentially large or unpredictable.

1 Like