Skip to content

Instantly share code, notes, and snippets.

@teocomi
Created March 27, 2018 10:26
Show Gist options
  • Save teocomi/1fdeb52730ad457ae5bb404f130686f9 to your computer and use it in GitHub Desktop.
Save teocomi/1fdeb52730ad457ae5bb404f130686f9 to your computer and use it in GitHub Desktop.
Get Revit Elements by UniqueID (GUID) from Dynamo
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import ElementId
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("System")
from System.Collections.Generic import List
doc = DocumentManager.Instance.CurrentDBDocument
guids = IN[0]
if not isinstance(guids, list):
guids = [guids]
elems = []
for g in guids:
hexid = g[37:]
id = int(hexid, 16)
elem = doc.GetElement(ElementId(id));
elems.append(elem)
OUT = elems
@Miguel-Ruiz-uk
Copy link

Change line 21 to be:

hexid = str(g[37:])

Worked for me in Revit 2022, Dynamo 2.12.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment