The elements that are shown as selected in the Revit user-interface.
Namespace: Autodesk.Revit.UI.Selection
Assembly: RevitAPIUI (in RevitAPIUI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Field Value
The selected elements.Remarks
PickOne and WindowSelect add to this set because they modify the set of elements selected in the user-interface after the External Command is complete. Selections made with PickObject, PickObjects, and PickElementsByRectangle do not persist after the External Command is complete, and therefore they do not affect this property.
Examples

private void ChangeSelection(UIDocument uidoc)
{
// Get selected elements from current document.
ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();
// Display current number of selected elements
TaskDialog.Show("Revit", "Number of selected elements: " + selectedIds.Count.ToString());
// Go through the selected items and filter out walls only.
ICollection<ElementId> selectedWallIds = new List<ElementId>();
foreach (ElementId id in selectedIds)
{
Element elements = uidoc.Document.GetElement(id);
if (elements is Wall)
{
selectedWallIds.Add(id);
}
}
// Set the created element set as current select element set.
uidoc.Selection.SetElementIds(selectedWallIds);
// Give the user some information.
if (0 != selectedWallIds.Count)
{
TaskDialog.Show("Revit", selectedWallIds.Count.ToString() + " Walls are selected!");
}
else
{
TaskDialog.Show("Revit","No Walls have been selected!");
}
}

Private Sub ChangeSelection(uidoc As UIDocument)
' Get selected elements from current document.
Dim selectedIds As ICollection(Of ElementId) = uidoc.Selection.GetElementIds()
' Display current number of selected elements
TaskDialog.Show("Revit", "Number of selected elements: " & selectedIds.Count.ToString())
' Go through the selected items and filter out walls only.
Dim selectedWallIds As ICollection(Of ElementId) = New List(Of ElementId)()
For Each id As ElementId In selectedIds
Dim elements As Element = uidoc.Document.GetElement(id)
If TypeOf elements Is Wall Then
selectedWallIds.Add(id)
End If
Next
' Set the created element set as current select element set.
uidoc.Selection.SetElementIds(selectedWallIds)
' Give the user some information.
If 0 <> selectedWallIds.Count Then
TaskDialog.Show("Revit", selectedWallIds.Count.ToString() & " Walls are selected!")
Else
TaskDialog.Show("Revit", "No Walls have been selected!")
End If
End Sub