Collect all categories in a project

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:
			model_cat.append(Revit.Elements.Category.ById(c.Id.IntegerValue))
		else:
			continue

Hi,

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.

Marcel

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

subscript

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)

2 Likes

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.
Thoughts?

You can collect them.

in c# it is something like this:

        var linkColl= new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument);
        linkColl.OfClass(typeof(RevitLinkInstance));
        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.
Select%20All%20Elements
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:
Sum%20Volume%20of%20Conc%20per%20Level

From the Sastrugi Package.


image
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 :

Get%20elements

4 Likes

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

@Ewan_Opie
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.