Skip to content

Instantly share code, notes, and snippets.

@sabeelcoder
Forked from johnpierson/GetModelElements.py
Created March 19, 2020 05:09
Show Gist options
  • Save sabeelcoder/7736228bf98428ee0798378cc8a59026 to your computer and use it in GitHub Desktop.
Save sabeelcoder/7736228bf98428ee0798378cc8a59026 to your computer and use it in GitHub Desktop.
This is a python script for Dynamo that allows you to collect all model elements in a Revit model.
import clr
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import FilteredElementCollector
# our current document and model elements
doc = DocumentManager.Instance.CurrentDBDocument
allElements = FilteredElementCollector(doc).WhereElementIsNotElementType().ToElements()
# lists to use for results, faillist is if we ever need it
modelElements = []
failList = []
# iterate through the elements and see if it has model characteristics
for i in allElements:
try:
if i.Category.HasMaterialQuantities:
modelElements.append(i)
except:
failList.append(i)
# output the model elements
OUT = modelElements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment