4.13 Family Acrobatics
Family -> FamilyType -> FamilyInstance -> FamilyType -> Family
Going Between FamilyInstance, FamilyType and Family
The Revit application uses a hard-coded hierarchy between Family, FamilyType and FamilyInstance objects. A family may contain many family types, a family type may be placed many times.
When working with scripts, I often need to go between accessing a FamilyInstance’s parameters, its Type Parameters and sometimes Family. The Revit API provides methods to move between these in a straightforward manner.
Moving Upstream from FamilyInstance -> FamilyType -> Family
Each FamilyInstance will derive from a single FamilyType. Likewise, each FamilyType will be defined by a single Family in the document. We can move upstream from FamilyInstance to Family like so:
Moving Downstream from Family -> FamilyTypes -> FamilyInstances
This way is more complicated; there is a many-to-one relationship between a Family object and its many potential FamilyType objects. Likewise, there could be many placed FamilyInstances of any FamilyType. To get all family_types of a family, we could use:
Finding all FamilyInstance objects of a given Type is less straightforward - we'll first need to create a FamilyInstanceFilter using the Id of the required FamilyType.
On Line 9 above, we create the FamilyInstanceFilter, which takes our document and the FamilyType's Id as arguments. We can then pass this in as a modifier to the FilteredElementCollector on Line 10.
Last updated