Skip to content

Instantly share code, notes, and snippets.

@johnpierson
Created January 4, 2021 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnpierson/40c6e8a90a77d25768842e7890c73f0f to your computer and use it in GitHub Desktop.
Save johnpierson/40c6e8a90a77d25768842e7890c73f0f to your computer and use it in GitHub Desktop.
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
#offer the user the selection
elementReferences = uidoc.Selection.PickObjects(Selection.ObjectType.Element, 'Pick model elements')
#our list to append selection results to
elements = []
#obtain the elements via the id
for i in elementReferences:
try:
elements.append(doc.GetElement(i.ElementId))
except:
elements.apped([])
OUT = elements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment