Family.FamilyCategory
Property
Description:
Retrieves or sets a Category object that represents the category or sub category in which the elements ( this family could generate ) reside.
Retrieves or sets a Category object that represents the category or sub category in which the elements ( this family could generate ) reside.
Remarks:
All category objects can be retrieved from the application by using the Categories property of the Application.Settings object.
All category objects can be retrieved from the application by using the Categories property of the Application.Settings object.
Examples
public void GetBeamAndColumnSymbols(Document document)
{
List<FamilySymbol> columnTypes = new List<FamilySymbol>();
List<FamilySymbol> framingTypes = new List<FamilySymbol>();
FilteredElementCollector collector = new FilteredElementCollector(document);
ICollection<Element> elements = collector.OfClass(typeof(Family)).ToElements();
foreach(Element element in elements)
{
Family family = element as Family;
Category category = family.FamilyCategory;
if (null != category)
{
ISet<ElementId> familySymbolIds = family.GetFamilySymbolIds();
if (BuiltInCategory.OST_StructuralColumns == category.BuiltInCategory)
{
foreach (ElementId id in familySymbolIds)
{
FamilySymbol symbol = family.Document.GetElement(id) as FamilySymbol;
columnTypes.Add(symbol);
}
}
else if (BuiltInCategory.OST_StructuralFraming == category.BuiltInCategory)
{
foreach (ElementId id in familySymbolIds)
{
FamilySymbol symbol = family.Document.GetElement(id) as FamilySymbol;
framingTypes.Add(symbol);
}
}
}
}
string message = "Column Types: ";
foreach (FamilySymbol familySymbol in columnTypes)
{
message += "\n" + familySymbol.Name;
}
TaskDialog.Show("Revit",message);
}
Exceptions
Exception | Condition |
---|---|
ArgumentException | Thrown when the input category cannot be assigned to this family. |
ArgumentNullException | Thrown when the input category is. |