Revit 2025 API
CategoriesNew |
Add a new subcategory into the Autodesk Revit document.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public Category NewSubcategory( Category parentCategory, string name )
Public Function NewSubcategory ( parentCategory As Category, name As String ) As Category
public: Category^ NewSubcategory( Category^ parentCategory, String^ name )
member NewSubcategory : parentCategory : Category * name : string -> Category
Parameters
Return Value
CategoryIf successful, the newly created subcategory.

Exception | Condition |
---|---|
ArgumentNullException | Thrown when the input argument-"parentCategory" or "name"-is . |
ArgumentException | Thrown when the input argument-"parentCategory"-cannot add subcategory. Thrown when the input argument-"name"-is an illegal name. |
InvalidOperationException | Thrown when subcategory creation failed. |

public void AssignSubCategory(Document document, GenericForm extrusion) { // create a new subcategory Category cat = document.OwnerFamily.FamilyCategory; Category subCat = document.Settings.Categories.NewSubcategory(cat, "NewSubCat"); // create a new material and assign it to the subcategory ElementId materialId = Material.Create(document, "Wood Material"); subCat.Material = document.GetElement(materialId) as Material; // assign the subcategory to the element extrusion.Subcategory = subCat; }
Public Sub AssignSubCategory(document As Document, extrusion As GenericForm) ' create a new subcategory Dim cat As Category = document.OwnerFamily.FamilyCategory Dim subCat As Category = document.Settings.Categories.NewSubcategory(cat, "NewSubCat") ' create a new material and assign it to the subcategory Dim materialId As ElementId = Material.Create(document, "Wood Material") subCat.Material = TryCast(document.GetElement(materialId), Material) ' assign the subcategory to the element extrusion.Subcategory = subCat 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