See below:
filters.dyn (6.5 KB)
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
view = UnwrapElement(IN[0])
name = IN[1]
selection_sets = FilteredElementCollector(doc).OfClass(SelectionFilterElement)
user_selection = []
for s in selection_sets:
if s.Name == name:
ids = s.GetElementIds()
user_selection = [doc.GetElement(e) for e in ids]
OUT = user_selection
The above script retrieves all selection sets in a document and matches a single selection set by name, returning the elements contained within.