Collect all categories in a project


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

Oh wonderful that seems to be working for me! Thanks for helping get this off the ground for me John.

1 Like

Glad to help out!

Is there a way to select All of the Elements in the entire Project? I have tried feeding individual categories into List.Create as you have shown. I am concerned that this method is prone to user error if someone forgets to add all of the categories in the project. Additionally I noticed that there are many solutions that involve Python coding. I am new to Dynamo so I am difficulty understanding the posts that use long strings of Python code.
I am creating a script that calculates the volume of all of the Concrete in the entire building. I successfully created a script that can calculate the volume of all the elements on a specific floor. Instead of using “All Elements at Level” I’d like my script to be based on all Elements in the Project. Is it possible to do this without first learning Python coding?
Below is my functioning script, based on materials on a given level:

From the Sastrugi Package.

Please note that this gathers everything! (Model elements, Annotations, Styles etc) so may take a while to run on a larger project. Hope this helps :grinning:

1 Like

Hi everyone,
by the way, are there any node that we can collect all categories in linked model ?
or we have to code inside python script

Like this :



Thanks @Alban_de_Chasteigner and Sastrugi Package :slight_smile:

1 Like

One major backside on the Sastrugi node is that it takes a lot of elements there is of no relevance in most cases. The exact reason why both @T_Pover and I have made nodes there have better selections than the Sastrugi nodes long before the Sastrugi node was released. This is what is described earliere in the post…

1 Like

hmmm… the code in the Sastrugi node looks exactly the same as the code I dismissed because it gave by far too many elements of no relevance. I simply don’t understand why anyone would use a node that collects elements of no interest in that amount!?

@erfajo You are correct as I used your coding as an inspiration for my intended purpose.

The intention of the node was “Big net, no holes” to catch all the :fish: for a total overview of project contents.
(I have a had quite a few projects where more data has been more helpful)

I see how the node name could cause some room for interpretation by the user, I appreciate the issue identification.:thinking: Perhaps a rename is required, from “Get All Elements in Project” to “Get Everything in Project” (will add this to the list for the next release)

I agree with the earlier postings by @erfajo and @T_Pover that show better targeted element extraction is essential to reduce graph complexity and run-times. :+1:

As always, I recommend that you (anyone reading this) check you are using the right tool for the job, in the right way. Any Q? the forum is always here :slight_smile:

1 Like

According to good customs a credit would have been appropriate in cases where the code is copied.

I did also make another node than the “Element.HasMaterialQuantities” that found elements used in the project, this node is called “Element.ByDocument”. It doesn’t get all the fish in the sea but it takes elements there under normal situations is of no interest.

In 95 out of 100 cases will “Element.HasMaterialQuantities” or @T_Pover node give what is needed, while “Element.ByDocument” covers the remaining. If I would have those extra you collect with my code, then it would be such a special case that I would only search for that category. It is using to much computational power and worst of all memory to collect all the fish in the sea.

To be honest and as argued in this post, I do believe that your node is waste of time and memory, and I can be allowed to say that since it is my code when it comes to all and I did abandon it because of that.

1 Like

hello, I wish to get all categories of elements placed in a project without getting the elements list.

the package nodes that I see give a full list of built-in categories in the project but I just need to filter the exiting categories used in a project.


It works this way but takes some time (About 2 minutes). Using all the info above (Thanks as always power users T_Pover, Konrad, etc… ) I got it to work (Did not delete room separations however lol). I am going to try to create some views and delete from those It might work faster. will keep you postedworking it out2.dyn (10.6 KB)

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:
		if c.SubCategories.Size > 0 or c.CanAddSubcategory:

	elif c.CategoryType == CategoryType.Annotation:
		if c.SubCategories.Size > 0 or c.CanAddSubcategory:
	elif c.CategoryType == CategoryType.AnalyticalModel:
		if c.SubCategories.Size > 0 or c.CanAddSubcategory:
	elif c.CategoryType == CategoryType.Internal:
		if c.SubCategories.Size > 0 or c.CanAddSubcategory:

OUT = model_cat, anno_cat, ana_cat, internal_cat

how to run that script from a list of Document Revit files instead of the Current document opened?7


Read carefully :slight_smile:

Hello man, I hope everything is going well for you. Could you please explain to me how could I take out all the elements I have in my Revit model through nodes/python?
Moreover, I want to use them for taking out the quantity-takeoff and afterward for costing thus it would be better if you could be of any help in this domain too. Thanks