Collect all categories in a project

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:

1 Like

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


First, I have to admit that the dynamo team have provided nodes that could do exactly what I tried to code in python, namely colleting all elements by a list by “Natural Category Name”.
Secondly, have I turned the code collecting elements that has materials into a node named as Element.HasMaterialQuantities". The node are now included in the “DanEDU Dynamo” package.

Home.dyn (6.4 KB)


Now what if we wanted to save all these out to a folder?

Working through the solutions provided I am unable to find and access the RVT Links built-in category which (hopefully) would allow access to the reference Revit models in the project and begin creating associations across models. The warning in Dynamo is this:

Warning: Category.ByName operation failed. 
The selected category is not valid in this document.

I’m curious what would make a category ‘valid’ ? The only thing that comes to mind is that the underlying code of Revit disallows access to Revit Links through the API at this time. I realize the API can only go so far and hinges on what the engineers at Autodesk reveal to us common folk in the API.

You can collect them.

in c# it is something like this:

        var linkColl= new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument);
        var elements = linkColl.ToElements();
1 Like