Selection

Selection

You can get the selected objects from the current active document using the UIDocument.Selection.GetElementIds() method which returns a collection fo ElementIds of the selected elements. The collection returned by this method can be used directly with FilteredElementCollector to filter the selected elements.

The Selection object can also be used to change the current selection programmatically using the SetElementIds() method.