You can get the selected objects from the current active document using the UIDocument.Selection.Elements property. The selected objects are in an ElementSet in Revit. From this Element set, all selected Elements are retrieved. The Selection object can also be used to change the current selection programmatically.
Alternatively, the Selection.GetElementIds() method retrieves the same set of elements as the Selection.Elements property. The collection returned by this method can be used directly with FilteredElementCollector to filter the selected elements.