I have a question is it possible to get all elements from the durrent model?
I want to get all elements without selecting or using All Elements in Active View.
So basically I want a list with all made Revit model elements.
I have tried something with Python but i can only make it work when I have a view.
My code:
import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference(‘System’)
from System.Collections.Generic import List
You don’t need to use a view as input for the FilteredElementCollector. Have a look at the RevitAPIdocs. It also has a constructor that only takes a Document as an argument.
Hey AmolShah, thanks I got all the elements
I have another question. With this code I get also the elements which are not modled is it possible to get only the modled elements?
Now I even get elements which aren not modled like “Electrical Load Classification Parameter Element”
@Lunzur This should get you all the elements from All Model Categories in your document.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
#allElements = FilteredElementCollector(doc).WhereElementIsNotElementType().WhereElementIsViewIndependent().ToElements()
allElements = FilteredElementCollector(doc).WhereElementIsNotElementType().ToElements()
filteredElements = []
for element in allElements:
if element.Category != None and element.Parameters.Size > 0 and element.HasPhases:
if element.Category.CategoryType == CategoryType.Model and (element.Category.SubCategories.Size > 0 or element.Category.CanAddSubcategory):
filteredElements.append(element)
OUT = filteredElements
This works for me on my project but you might have to modify the if conditions based on the output you require.
Hey AmolShah,
WOW thank you very much It works realy well, the script does what I want.
Do you know any good tutoriols for Dynamo Python, I just recentrly start learning python