Skip to content

Instantly share code, notes, and snippets.

@teocomi
Last active November 23, 2023 01:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teocomi/c50c3422b92a3198c6c80c214b22904d to your computer and use it in GitHub Desktop.
Save teocomi/c50c3422b92a3198c6c80c214b22904d to your computer and use it in GitHub Desktop.
Select Revit Elements by ID 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
uiapp = DocumentManager.Instance.CurrentUIApplication
ids = IN[0]
# if it's not a list, make it a list
if not isinstance(ids, list):
ids = [ids]
# convert to element ids
elemIds = []
for id in ids:
elemIds.append(ElementId(id))
# cast to icollection and select
uiapp.ActiveUIDocument.Selection.SetElementIds(List[ElementId](elemIds));
#Assign your output to the OUT variable.
OUT = 0
@shuixing85
Copy link

works great, thanks for sharing : )

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