Add a new subcategory into the Autodesk Revit document.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Syntax
Visual Basic |
---|
Public Function NewSubcategory ( _
parentCategory As Category, _
name As String _
) As Category |
Visual C++ |
---|
public:
Category^ NewSubcategory(
Category^ parentCategory,
String^ name
) |
Return Value
If successful, the newly created subcategory.
Examples
CopyC#
public void AssignSubCategory(Document document, GenericForm extrusion)
{
Category cat = document.OwnerFamily.FamilyCategory;
Category subCat = document.Settings.Categories.NewSubcategory(cat, "NewSubCat");
ElementId materialId = Material.Create(document, "Wood Material");
subCat.Material = document.GetElement(materialId) as Material;
extrusion.Subcategory = subCat;
}
CopyVB.NET
Public Sub AssignSubCategory(document As Document, extrusion As GenericForm)
Dim cat As Category = document.OwnerFamily.FamilyCategory
Dim subCat As Category = document.Settings.Categories.NewSubcategory(cat, "NewSubCat")
Dim materialId As ElementId = Material.Create(document, "Wood Material")
subCat.Material = TryCast(document.GetElement(materialId), Material)
extrusion.Subcategory = subCat
End Sub
Exceptions
See Also