SelectionPick |
Namespace: Autodesk.Revit.UI.Selection
Assembly: RevitAPIUI (in RevitAPIUI.dll) Version: 25.0.0.0 (25.0.0.0)
public IList<Element> PickElementsByRectangle( string statusPrompt )
Public Function PickElementsByRectangle ( statusPrompt As String ) As IList(Of Element)
public: IList<Element^>^ PickElementsByRectangle( String^ statusPrompt )
member PickElementsByRectangle : statusPrompt : string -> IList<Element>
Parameters
- statusPrompt String
- The message shown on the status bar.
Return Value
IListElementA collection of elements selected by the user.
Note: if the user cancels the operation (for example, through ESC), the method will throw an OperationCanceledException instance.

Exception | Condition |
---|---|
ArgumentNullException | Thrown when the statusPrompt is . |
OperationCanceledException | Thrown when the Revit user cancelled this operation. Thrown when the Revit user tried to switch the active view, close the active document or Revit application when responding to this mode. |
ForbiddenForDynamicUpdateException | Thrown if this method is called during dynamic update. |

Revit users will be permitted to manipulate the Revit view (zooming, panning, and rotating the view), but will not be permitted to click other items in the Revit user interface. Users are not permitted to switch the active view, close the active document or Revit application in the pick session, otherwise an exception will be thrown.
The selection will not be automatically added to the active selection buffer.
Note: this method must not be called during dynamic update, otherwise ForbiddenForDynamicUpdateException will be thrown.

// Use the rectangle picking tool to identify model elements to select. IList<Element> pickedElements = uidoc.Selection.PickElementsByRectangle("Select by rectangle"); if (pickedElements.Count > 0) { // Collect Ids of all picked elements IList<ElementId> idsToSelect = new List<ElementId>(pickedElements.Count); foreach (Element element in pickedElements) { idsToSelect.Add(element.Id); } // Update the current selection uidoc.Selection.SetElementIds(idsToSelect); TaskDialog.Show("Revit", string.Format("{0} elements added to Selection.", idsToSelect.Count)); }
' Use the rectangle picking tool to identify model elements to select. Dim pickedElements As IList(Of Element) = uidoc.Selection.PickElementsByRectangle("Select by rectangle") If pickedElements.Count > 0 Then ' Collect Ids of all picked elements Dim idsToSelect As IList(Of ElementId) = New List(Of ElementId)(pickedElements.Count) For Each element As Element In pickedElements idsToSelect.Add(element.Id) Next ' Update the current selection uidoc.Selection.SetElementIds(idsToSelect) TaskDialog.Show("Revit", String.Format("{0} elements added to Selection.", idsToSelect.Count)) End If
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.