How to retrieve elements from a selection set in revit

hello, is there a node, or a way to retrieve the elements that are in a particular selection set in revit? Like the opposite of this node. this one writes to, but I want a reads from node… any ideas?
Thanks!

Here is a similar script I wrote a while ago. It currently only works for a single selection set, but it can be easily adapted to account for a list of selection sets.

1 Like

Here is how to retrieve an already created selection set. If you have more than one loaded in your project, you’ll want to filter by the name of the selection set prior to inputting or retrieving the selection set at the given index.
Hope this helps!

3 Likes

Ok now I cant seem to get the first node to work to set the selection set. What do you think the problem is here?

thanks so much cgartland, but this script that you wrote does not seem to work in dynamo 1.3.4. Is it supposed to?

The .dyn was authored in Dynamo 2.x, so it can’t be opened in Dynamo 1.x. However, you can replicate it in your version of Dynamo by referencing the screenshot and the code pasted below it.

1 Like

IN[0] connect a string with the name of the selection set, use this python code:

# Import the required libraries
import clr
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import FilteredElementCollector, SelectionFilterElement

# Import RevitServices
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager

# Get the current Revit document
doc = DocumentManager.Instance.CurrentDBDocument

OUT = [doc.GetElement(id) for id in next((filter_elem.GetElementIds() for filter_elem in FilteredElementCollector(doc).OfClass(SelectionFilterElement).ToElements() if filter_elem.Name == IN[0]), [])]