Skip to content

Instantly share code, notes, and snippets.

@teocomi
Created March 27, 2018 10:26
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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
@RENUBIM360
Copy link

sorry did not worked... can you pls add something for adoptive component and revit system family. Showing error in line 21.

@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