Get a Revit family type from a FamilySymbol, with Python

Hi everyone,

I’m trying to place several instances in a model, using the “doc.Create.NewFamilyInstance()” method.
Hence, I want to narrow my list of family types down to a single type, to be passed as a FamilySymbol parameter.
I do get the Revit family I want, however, the Revit family contains several types and I just can’t boil it down to one of them.

Here’s a snapshot of what works so far:

Would really appreciate some help.

Your fam_sys_lst collector collects all elements of the FamilySymbol class.
There are multiple ways of getting only 1 item:

  • Indexing: e.g. fam_sys_lst[0] would return the first element of that list and is similar to the GetItemAtIndex node of Dynamo.
  • Narrow down your collector: This blog post gives good examples on how to use it.

a Familysymbol is a Type

to filter your collector try this:

filter_typ = [x for x in fam_symb_lst if x.Family.Name == "SP_2D Chair" and Element.Name.GetValue(x) == "40/40"][0]

Great, it worked!

I would like to select the type with a user controlled input, such as type name.
Thanks for the reply and the link, though. I’ll check it out.

Just another little question:
“x.Family.Name” and “Element.Name.GetValue” - are those pure API methods?
I mean, would they work outside of Dynamo environment (Python shell, C# addins and such)?
Thanks again!

x.Family.Name is is the combination of 2 properties (Revit API) and (Inherited from [Element ]

Element.Name.GetValue(objet) is a dotnet method to get value from a Property because Dynamo use IronPython
you can also use

Note: FamilySymbol.Name does not work due to a IronPython limitation

more info here

Great, thanks again!
Indeed, I was struggling with the FamilySymbol.Name method and couldn’t get why it keeps giving me errors.