| Revit 2015 API |
| Family..::..FamilyCategory Property |
| Family Class Example See Also |
Retrieves or sets a Category object that represents the category or sub category in which the elements
( this family could generate ) reside.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Syntax
Remarks
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) { FamilySymbolSet columnTypes = new FamilySymbolSet(); FamilySymbolSet framingTypes = new FamilySymbolSet(); 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 ((int)BuiltInCategory.OST_StructuralColumns == category.Id.IntegerValue) { foreach (ElementId id in familySymbolIds) { FamilySymbol symbol = family.Document.GetElement(id) as FamilySymbol; columnTypes.Insert(symbol); } } else if ((int)BuiltInCategory.OST_StructuralFraming == category.Id.IntegerValue) { foreach (ElementId id in familySymbolIds) { FamilySymbol symbol = family.Document.GetElement(id) as FamilySymbol; framingTypes.Insert(symbol); } } } } string message = "Column Types: "; FamilySymbolSetIterator fsItor = columnTypes.ForwardIterator(); fsItor.Reset(); while (fsItor.MoveNext()) { FamilySymbol familySybmol = fsItor.Current as FamilySymbol; message += "\n" + familySybmol.Name; } TaskDialog.Show("Revit",message); }
Public Sub GetBeamAndColumnSymbols(document As Document) Dim columnTypes As New FamilySymbolSet() Dim framingTypes As New FamilySymbolSet() Dim collector As New FilteredElementCollector(document) Dim elements As ICollection(Of Element) = collector.OfClass(GetType(Family)).ToElements() For Each element As Element In elements Dim family As Family = TryCast(element, Family) Dim category As Category = family.FamilyCategory If category IsNot Nothing Then Dim familySymbolIds As ISet(Of ElementId) = family.GetFamilySymbolIds() If CInt(BuiltInCategory.OST_StructuralColumns) = category.Id.IntegerValue Then For Each id As ElementId In familySymbolIds Dim symbol As FamilySymbol = TryCast(family.Document.GetElement(id), FamilySymbol) columnTypes.Insert(symbol) Next ElseIf CInt(BuiltInCategory.OST_StructuralFraming) = category.Id.IntegerValue Then For Each id As ElementId In familySymbolIds Dim symbol As FamilySymbol = TryCast(family.Document.GetElement(id), FamilySymbol) framingTypes.Insert(symbol) Next End If End If Next Dim message As String = "Column Types: " Dim fsItor As FamilySymbolSetIterator = columnTypes.ForwardIterator() fsItor.Reset() While fsItor.MoveNext() Dim familySybmol As FamilySymbol = TryCast(fsItor.Current, FamilySymbol) message += vbLf + familySybmol.Name End While TaskDialog.Show("Revit", message) End Sub
Exceptions
| Exception | Condition |
|---|---|
| Autodesk.Revit.Exceptions..::..ArgumentException | Thrown when the input category cannot be assigned to this family. |
| Autodesk.Revit.Exceptions..::..ArgumentNullException | Thrown when the input category is nullNothingnullptra null reference (Nothing in Visual Basic). |