How to Get All Categories in Revit API?

This is not complicated by any means. In fact it's just a single line to get all of them, and then we can filter down to any category with list comprehensions. Check my examples with Revit API + python.

Tags:  Revit API
Sep 2022

Let's get Categories!

This is not complicated by any means. In fact it's just a single line to get all of them, and then we can filter down to any category with list comprehensions. Have a look below and hopefully you will find what you looking for.

code
# GET ALL CATEGORIES 
all_categories = doc.Settings.Categories

# FILTER TO ANNOTATION CATEGORIES
cats_model      = [cat for cat in all_categories if cat.CategoryType == CategoryType.Model]
cats_annotation = [cat for cat in all_categories if cat.CategoryType == CategoryType.Annotation]
cats_analytical = [cat for cat in all_categories if cat.CategoryType == CategoryType.AnalyticalModel]
cats_internal   = [cat for cat in all_categories if cat.CategoryType == CategoryType.Internal]
code
# PRINT ALL INSTANCES OF MODEL CATEGORIES
for cat in cats_model:
	print(cat.Name)

Abutments
Air Systems
Air Terminals
Analysis Display Style
Analysis Results
Areas
Bearings
Bridge Cables
Bridge Decks
Bridge Framing
Cable Tray Fittings
Cable Tray Runs
Cable Trays
Casework
Ceilings
Columns
Communication Devices
Conduit Fittings
Conduit Runs
Conduits
Coordination Model
Curtain Grids
Curtain Panels
Curtain Systems
Curtain Wall Mullions
Data Devices
Detail Items
Doors
Duct Accessories
Duct Fittings
Duct Insulations
Duct Linings
Duct Placeholders
Duct Systems
Ducts
Electrical Circuits
Electrical Equipment
Electrical Fixtures
Electrical Spare/Space Circuits
Entourage
Expansion Joints
Filled region
Fire Alarm Devices
Flex Ducts
Flex Pipes
Floors
Furniture
Furniture Systems
Generic Models
HVAC Zones
Imports in Families
Lighting Devices
Lighting Fixtures
Lines
MEP Fabrication Containment
MEP Fabrication Ductwork
MEP Fabrication Hangers
MEP Fabrication Pipework
Masking Region
Mass
Materials
Mechanical Equipment
Mechanical Equipment Sets
Nurse Call Devices
Parking
Parts
Piers
Pipe Accessories
Pipe Fittings
Pipe Insulations
Pipe Placeholders
Pipe Segments
Pipes
Piping Systems
Planting
Plumbing Fixtures
Point Clouds
Project Information
RVT Links
Railings
Ramps
Raster Images
Rebar Shape
Roads
Roofs
Rooms
Routing Preferences
Security Devices
Shaft Openings
Sheets
Site
Spaces
Specialty Equipment
Sprinklers
Stairs
Structural Area Reinforcement
Structural Beam Systems
Structural Columns
Structural Connections
Structural Fabric Areas
Structural Fabric Reinforcement
Structural Foundations
Structural Framing
Structural Path Reinforcement
Structural Rebar
Structural Rebar Couplers
Structural Stiffeners
Structural Tendons
Structural Trusses
Switch System
Telephone Devices
Topography
Vibration Management
Walls
Water Loops
Windows
Wires
Zone Equipment

code
# PRINT SORTED CATEGORIES
for cat in sorted(cats_annotation, key=lambda x: x.Name):
	print(cat.Name)

Abutment Foundation Tags
Abutment Pile Tags
Abutment Tags
Abutment Wall Tags
Adaptive Points
Air Terminal Tags
Alignment Station Label Sets
Alignment Station Labels
Alignment Tags
Alignments
Analytical Beam Tags
Analytical Brace Tags
Analytical Column Tags
Analytical Floor Tags
Analytical Isolated Foundation Tags
Analytical Link Tags
Analytical Node Tags
Analytical Slab Foundation Tags
Analytical Wall Foundation Tags
Analytical Wall Tags
Anchor Tags
Annotation Crop Boundary
Approach Slab Tags
Area Load Tags
Area Tags
Assembly Tags
Bearing Tags
Bolt Tags
Brace in Plan View Symbols
Bridge Cable Tags
Bridge Deck Tags
Bridge Framing Tags
Cable Tray Fitting Tags
Cable Tray Tags
Callout Boundary
Callout Heads
Callouts
Cameras
Casework Tags
Ceiling Tags
Color Fill Legends
Communication Device Tags
Conduit Fitting Tags
Conduit Tags
Connection Symbols
Contour Labels
Crop Boundaries
Curtain Panel Tags
Curtain System Tags
Data Device Tags
Detail Item Tags
Dimensions
Displacement Path
Door Tags
Duct Accessory Tags
Duct Color Fill
Duct Color Fill Legends
Duct Fitting Tags
Duct Insulation Tags
Duct Lining Tags
Duct Tags
Electrical Equipment Tags
Electrical Fixture Tags
Elevation Marks
Elevations
Expansion Joint Tags
Fire Alarm Device Tags
Flex Duct Tags
Flex Pipe Tags
Floor Tags
Foundation Span Direction Symbol
Furniture System Tags
Furniture Tags
Generic Annotations
Generic Model Tags
Grid Heads
Grids
Guide Grid
Hole Tags
Internal Area Load Tags
Internal Line Load Tags
Internal Point Load Tags
Keynote Tags
Level Heads
Levels
Lighting Device Tags
Lighting Fixture Tags
Line Load Tags
MEP Fabrication Containment Tags
MEP Fabrication Ductwork Tags
MEP Fabrication Hanger Tags
MEP Fabrication Pipework Tags
Mass Floor Tags
Mass Tags
Matchline
Material Tags
Mechanical Equipment Set Boundary Lines
Mechanical Equipment Set Tags
Mechanical Equipment Tags
Multi-Category Tags
Multi-Rebar Annotations
Nurse Call Device Tags
Panel Schedule Graphics
Parking Tags
Part Tags
Path of Travel Tags
Pier Cap Tags
Pier Column Tags
Pier Foundation Tags
Pier Pile Tags
Pier Tags
Pier Tower Tags
Pier Wall Tags
Pipe Accessory Tags
Pipe Color Fill
Pipe Color Fill Legends
Pipe Fitting Tags
Pipe Insulation Tags
Pipe Tags
Plan Region
Planting Tags
Plate Tags
Plumbing Fixture Tags
Point Load Tags
Profile Tags
Property Line Segment Tags
Property Tags
Railing Tags
Rebar Cover References
Rebar Set Toggle
Reference Lines
Reference Planes
Reference Points
Render Regions
Revision Cloud Tags
Revision Clouds
Roof Tags
Room Tags
Schedule Graphics
Scope Boxes
Section Boxes
Section Line
Section Marks
Sections
Security Device Tags
Shear Stud Tags
Site Tags
Space Tags
Span Direction Symbol
Specialty Equipment Tags
Spot Coordinates
Spot Elevation Symbols
Spot Elevations
Spot Slopes
Sprinkler Tags
Stair Landing Tags
Stair Paths
Stair Run Tags
Stair Support Tags
Stair Tags
Stair Tread/Riser Numbers
Structural Annotations
Structural Area Reinforcement Symbols
Structural Area Reinforcement Tags
Structural Beam System Tags
Structural Column Tags
Structural Connection Tags
Structural Fabric Reinforcement Symbols
Structural Fabric Reinforcement Tags
Structural Foundation Tags
Structural Framing Tags
Structural Path Reinforcement Symbols
Structural Path Reinforcement Tags
Structural Rebar Coupler Tags
Structural Rebar Tags
Structural Stiffener Tags
Structural Tendon Tags
Structural Truss Tags
System-Zone Tags
Telephone Device Tags
Text Notes
Title Blocks
Vibration Damper Tags
Vibration Isolator Tags
View Reference
View Titles
Viewports
Wall Tags
Weld Tags
Window Tags
Wire Tags
Zone Tags

code
# PRINT SORTED CATEGORIES
for cat in sorted(cats_analytical, key=lambda x: x.Name):
	print(cat.Name)

Analytical Beams
Analytical Braces
Analytical Columns
Analytical Floors
Analytical Foundation Slabs
Analytical Isolated Foundations
Analytical Links
Analytical Nodes
Analytical Pipe Connections
Analytical Surfaces
Analytical Wall Foundations
Analytical Walls
Boundary Conditions
Structural Internal Loads
Structural Load Cases
Structural Loads
System-Zones

code
# PRINT SORTED CATEGORIES
for cat in sorted(cats_internal, key=lambda x: x.Name):
	print(cat.Name)

Assemblies
Model Groups
Schedules
Views

How do we use categories?

There are many applications to categories. Since you found this article through google, I assume you already have an idea in mind, how you would want to use these categories. But I will leave here a simple example how to hide certain categories from a View.

code
# START TRANSACTION
t = Transaction(doc, __title__)
t.Start()

# GET ANNOTATION CATEGORIES
all_categories  = doc.Settings.Categories
cats_annotation = [cat for cat in all_categories if cat.CategoryType == CategoryType.Annotation]

# HIDE ANNOTATION CATEGORIES EXCEPT SECTIONBOX
exclude = [BuiltInCategory.OST_SectionBox]
for cat in cats_annotation:
    if cat.BuiltInCategory in exclude:
        continue
    view.SetCategoryHidden(cat.Id, True)

t.Commit()

⌨️ Happy Coding!

— Erik Frits