FamilyFamilyCategory Property |
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.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic Category FamilyCategory { get; set; }
Public Property FamilyCategory As Category
Get
Set
public:
property Category^ FamilyCategory {
Category^ get ();
void set (Category^ value);
}
member FamilyCategory : Category with get, set
Property Value
Category
Exceptions
RemarksAll category objects can be retrieved from the application by using the Categories property
of the Application.Settings object.
Examplepublic 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);
}
Public Sub GetBeamAndColumnSymbols(document As Document)
Dim columnTypes As New System.Collections.Generic.List(Of FamilySymbol)
Dim framingTypes As New System.Collections.Generic.List(Of FamilySymbol)
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 BuiltInCategory.OST_StructuralColumns = category.BuiltInCategory Then
For Each id As ElementId In familySymbolIds
Dim symbol As FamilySymbol = TryCast(family.Document.GetElement(id), FamilySymbol)
columnTypes.Add(symbol)
Next
ElseIf BuiltInCategory.OST_StructuralFraming = category.BuiltInCategory Then
For Each id As ElementId In familySymbolIds
Dim symbol As FamilySymbol = TryCast(family.Document.GetElement(id), FamilySymbol)
framingTypes.Add(symbol)
Next
End If
End If
Next
Dim message As String = "Column Types: "
For Each familySybmol As FamilySymbol In columnTypes
message += vbLf + familySybmol.Name
Next
TaskDialog.Show("Revit", message)
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also