Collect all categories in a project

Hey Konrad,

what should I wright i OUT = ??? to get the list out with your code ?

OUT = elements

1 Like

I think I’m maybe starting the script the wrong way

What’s your error?

operation failed.
Traceback (most recent call last):
File “”, line 16, in
NameError: name ‘List’ is not defined


You need a reference for Collections.Generic. Try this:

from System.Collections.Generic import *

That kinda worked, now there is not a fail but the list is empty

you probably want this as well. This will wrap Revit API elements into Dynamo

import Revit

Also do you have doors in that project? I mean, this is a multi category element collector not a Category collector. It returns all elements of category. I would actually propose you use the OOTB noes for this and a method that @T_Pover suggested. It’s not different.

okay so the node called get Categories with builtins would be the one to use ? and thanks again for all the help :slight_smile:

Just getting every model category in the model bothered me for a while as well, so I finally got this working:


@T_Pover : is it possible to get the code for that node… looks like a good solution :slight_smile:

I just feed the desired Built in category names to my super collect node, not all of them.

Sure, it’s part of my package: MEPover

import clr
from Autodesk.Revit.DB import *

import Revit

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

doc = DocumentManager.Instance.CurrentDBDocument
categories = doc.Settings.Categories

model_cat = []
anno_cat = []
ana_cat = []
internal_cat = []

for c in categories:
	if c.CategoryType == CategoryType.Model:
	elif c.CategoryType == CategoryType.Annotation:
	elif c.CategoryType == CategoryType.AnalyticalModel:
	elif c.CategoryType == CategoryType.Internal:

OUT = model_cat, anno_cat, ana_cat, internal_cat

Please note, I refrained from using ‘anal_cat’ :slight_smile:


hmmm… the ‘CategoryType.Model’ seems to give elements which is unwanted. Like imported dwgs, project information, materials, masking regions, sheets etc. There is a really a need for methods retrieving only geometric elements.

That is indeed true. The API documentation also mentions this: "The category type determines if the category is shown in the Visibility/Graphics settings grouped with the model,annotation, or analytical model categories. Note that import categories are also “model” but will be shown separately in the dialog. Some categories not shown in the dialog and will return Internal for the category type."
I don’t know if there’s a way to filter it besides a string comparison.

I guess you could narrow it down a bit further like this:

for c in categories:
	if c.CategoryType == CategoryType.Model:
		if c.SubCategories.Size > 0 or c.CanAddSubcategory:


I dont know anything about this but has MaterialVolume seems plausible to me.
I know this is a field in the revit database exported using DBLink.


I tried the HasMaterialQuantities property as well, but that will omit a lot of categories that are actually part of the model categories.

I was affraid that this could be the case. In my testbed did ‘HasMaterialQuantities’ capture all elements, but I couldnt be sure that this would be the case in all cases.
I will stick to my ‘own’ list example, this will for sure give me what I want :slight_smile:

1 Like