Collect all categories in a project

Hello Dynamo community.

I’m am currently working with a project where a need to make a list of all elements in the project, with there name and classification code,

At this point I know how to do that with one category, but I would like to know if any of you knew a way , so I can select all the categories in the project.

Thank you in advance

1 Like


import clr

# Import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager

# Import RevitAPI
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

OUT = [i.Name for i in doc.Settings.Categories]

Hey Tomasz thanks for the fast replay

Wow that was effektiv

but how can i convert it so i can select all elements of those categories ?

You need to specify category and use collector:

1 Like

Hmmm can i get the collector to instead of “just” walls all the categories in the project ?

and again Thanks :slight_smile:

U can get whatever you want to:

last an final question, how do i add one of those in the script ?

im a little knew i python :slight_smile:

Change line
where xxx is category from the link
OST_Walls to for example OST_Windows etc

thanks, and i can just keep on adding categories, in the same code ? :slight_smile:

I think that I’m doing it wrong hehe

walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls)
windows = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Windows)
doors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors)

I still think I’m doing it wrong

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

Like Tomasz says it’s probably easier doing this with nodes:

This will also get you all annations families though. If you want to use this for take-off then you’re better of creating seperate category nodes and combining those into a single list like so:


The FilteredElementCollector gives you all elements in Revit, however it won’t let you access them without some kind of filter.

If you really want ALL elements in the Revit DB, you can trick the filter like this (from:

As you can see this gives me thousands of elements in a fresh opened file from template:

import clr

from Autodesk.Revit.DB import *

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

coll = FilteredElementCollector( doc )
coll.WherePasses(LogicalOrFilter(ElementIsElementTypeFilter( False ),ElementIsElementTypeFilter( True )))

OUT = [e.Id for e in coll]

Okay thank you guys,

project is that i need all the elements used in the project, an make a control, if this elements have a certain parameter ore not, and after that see what there is written in that parameter :slight_smile:

and sorry for all the beginners python questions

Try this…


Thanks very very much all i got the solution i wanted and more :slight_smile: you were all a big help

I ended up using t_pover and Vikram for to different script.

1 Like


That’s not very efficient. You can do a multi category filter instead:

builtInCats = List[BuiltInCategory]()
filter1 = ElementMulticategoryFilter(builtInCats)

elements = FilteredElementCollector(doc).WherePasses(filter1).ToElements()

I know it might be frustrating to run into people that know very little coding, but at the same time where do they learn the basics if not here. I would say that its quite to the contrary: This is the forum to learn some Python basics. Of course there are others like Stack Overflow or simply picking up an online course and/or a book. Everyone learns in a different way. It’s all good mate.