Collect all categories in a project

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:

3 Likes

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: http://thebuildingcoder.typepad.com/blog/2010/06/filter-for-all-elements.html)

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

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
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]
2 Likes

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…

5 Likes

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

@Tomasz_Puchala

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

builtInCats = List[BuiltInCategory]()
builtInCats.Add(BuiltInCategory.OST_Doors)
builtInCats.Add(BuiltInCategory.OST_Windows)
builtInCats.Add(BuiltInCategory.OST_CeilingOpening)
builtInCats.Add(BuiltInCategory.OST_FloorOpening)
builtInCats.Add(BuiltInCategory.OST_RoofOpening)
 
filter1 = ElementMulticategoryFilter(builtInCats)

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

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.

10 Likes

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?

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

:slight_smile:

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

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: