Share

Categories Class

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.3.0.0 (25.3.0.0)

Syntax

C#

public class Categories : CategoryNameMap

The Categories type exposes the following members.

Properties

 NameDescription
Public propertyIsEmptyWhether or not the list of top-level categories is empty.
(Overrides CategoryNameMap.IsEmpty)
Public propertyCode exampleIsReadOnlyIdentifies if the object is read-only or modifiable.
(Inherited from APIObject)
Public propertyItem[BuiltInCategory] Retrieves a category object corresponding to a BuiltInCategory id.
Public propertyItem[String]Gets a category which has the specified name from this list of top-level categories.
(Overrides CategoryNameMap.Item[String])
Public propertySizeThe total number of top-level categories in the document.
(Overrides CategoryNameMap.Size)

Methods

 NameDescription
Public methodClearRemoves every category from the map, rendering it empty.
(Inherited from CategoryNameMap)
Public methodContainsIdentifies if a category which has the specified name is in the list of top-level categories.
(Overrides CategoryNameMap.Contains(String))
Public methodDisposeCauses the object to release immediately any resources it may be utilizing.
(Inherited from APIObject)
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodEraseRemoves a category with the specified name from the map.
(Inherited from CategoryNameMap)
Public methodForwardIteratorRetrieves a forward moving iterator to the map.
(Overrides CategoryNameMap.ForwardIterator())
Public methodGetEnumeratorRetrieves a forward moving iterator to the map.
(Overrides CategoryNameMap.GetEnumerator())
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodInsertInserts the specified category with the specified name into the map.
(Overrides CategoryNameMap.Insert(String, Category))
Public methodCode exampleNewSubcategoryAdd a new subcategory into the Autodesk Revit document.
Public methodReverseIteratorRetrieves a backward moving iterator to the map.
(Overrides CategoryNameMap.ReverseIterator())
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)

Remarks

Use this object to retrieve categories by name or by BuiltInCategory id.

Example

C#

// Get settings of current document
Settings documentSettings = document.Settings;

// Get all categories of current document
Categories groups = documentSettings.Categories;

// Show the number of all the categories to the user
String prompt = "Number of all categories in current Revit document:" + groups.Size;

// get Floor category according to OST_Floors and show its name
Category floorCategory = groups.get_Item(BuiltInCategory.OST_Floors);
prompt += floorCategory.Name;

// Give the user some information
TaskDialog.Show("Revit",prompt);

VB

' Get settings of current document
Dim documentSettings As Settings = document.Settings

' Get all categories of current document
Dim groups As Categories = documentSettings.Categories

' Show the number of all the categories to the user
Dim prompt As [String] = "Number of all categories in current Revit document:" + groups.Size

' get Floor category according to OST_Floors and show its name
Dim floorCategory As Category = groups.Item(BuiltInCategory.OST_Floors)
prompt += floorCategory.Name

' Give the user some information
TaskDialog.Show("Revit", prompt)

See Also

Reference

Was this information helpful?