Get all element types using revit api

Does someone know how to get all the element types of the active document using the API of Revit ? (python language)

Thanks!

Something like: FilteredElementCollector(doc).OfClass(ElementType).ToElements() ?

yeah, i’ve tried this one, but I don’t really know what to write at the ‘doc’ place exactly.

The Filtered Element Collector requires a Document object - this is the Revit document whose database you want to read. With all the usual copy/paste code it’d look like this:

import clr
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import System
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument

element_types = FilteredElementCollector(doc).OfClass(ElementType).ToElements()

OUT = element_types

Try that!

1 Like

thancks!

the documentManager line was the one I was looking for.