Selecting elements through Dynamo

I thought it would be quite simple but I can’t find a way to make Dynamo select elements in Revit model (I want to create a list of elements in Dynamo and then highlight them in Revit). Anyone can lead me how can I highlight elements (I know how to get the list, just don’t know how to create selection).

From the Springs package

image

3 Likes

Hi,

You can also use Select in Revit in HotGear package or Element.SelectInView in SteamNodes package.

2 Likes

Thanks you both - Springs package solved it. I was assuming there is OOTB solution for this.

Hi !

Just curious here. Isn’t there a way to select the elements via :

DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument.Selection.SetElementIds()

in Python ?

I tried several inputs be somehow could not get it to work… (Python told me that it was expecting an ICollection[ElementID] object ; no idea what it is)

Hi Mustapha,

You need to import the System collection in RevitServices to use ICollection (ICollection)

You will find an example below :

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from System.Collections.Generic import *

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

elements = UnwrapElement(IN[0])
select = []

for i in elements:
	select.append(i.Id)
	Icollection = List[ElementId](select)
	DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument.Selection.SetElementIds(Icollection)

OUT = elements
2 Likes

Thanks @Alban_de_Chasteigner !