Categories
The Categories object is a map that contains all the top-level Category objects within the Document.
Inheritance Hierarchy
System.Object
Autodesk.Revit.DB.APIObject
Autodesk.Revit.DB.CategoryNameMap
Autodesk.Revit.DB.Categories
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public class Categories : CategoryNameMap
The Categories type exposes the following members.
Properties
Name
Description
Public Property
IsEmpty
Whether or not the list of top-level categories is empty.
(Overrides CategoryNameMap.IsEmpty)
Public Property
Code Example
IsReadOnly
Identifies if the object is read-only or modifiable.
(Inherited from APIObject)
Public Property
Item.BuiltInCategory.
Retrieves a category object corresponding to a BuiltInCategory id.
Public Property
Item.String.
Gets a category which has the specified name from this list of top-level categories.
(Overrides
CategoryNameMap.Item.String.
)Public Property
Size
The total number of top-level categories in the document.
(Overrides
CategoryNameMap.Size
)Methods
Name
Description
Public Method
Clear
Removes every category from the map, rendering it empty.
(Inherited from CategoryNameMap)
Public Method
Contains
Identifies if a category which has the specified name is in the list of top-level categories.
(Overrides
CategoryNameMap.Contains(String)
)Public Method
Dispose
Causes the object to release immediately any resources it may be utilizing.
(Inherited from APIObject)
Public Method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object)
Public Method
Erase
Removes a category with the specified name from the map.
(Inherited from CategoryNameMap)
Public Method
ForwardIterator
Retrieves a forward moving iterator to the map.
(Overrides
CategoryNameMap.ForwardIterator.
)Public Method
GetEnumerator
Retrieves a forward moving iterator to the map.
(Overrides
CategoryNameMap.GetEnumerator.
)Public Method
GetHashCode
Serves as the default hash function.
(Inherited from Object)
Public Method
GetType
Gets the Type of the current instance.
(Inherited from Object)
Public Method
Insert
Inserts the specified category with the specified name into the map.
(Overrides
CategoryNameMap.Insert(String, Category)
)Public Method
Code Example
NewSubcategory
Add a new subcategory into the Autodesk Revit document.
Public Method
ReverseIterator
Retrieves a backward moving iterator to the map.
(Overrides
CategoryNameMap.ReverseIterator.
)Public Method
ToString
Returns a string that represents the current object.
(Inherited from Object)
Remarks
Use this object to retrieve categories by name or by BuiltInCategory id.
Example
// Get settings of current documentSettings documentSettings = document.Settings;
// Get all categories of current documentCategories groups = documentSettings.Categories;
// Show the number of all the categories to the userString prompt = "Number of all categories in current Revit document:" + groups.Size;
// get Floor category according to OST_Floors and show its nameCategory floorCategory = groups.get_Item(BuiltInCategory.OST_Floors);prompt += floorCategory.Name;
// Give the user some informationTaskDialog.Show("Revit",prompt);