© 2010 Autodesk
Introduction to Revit 2011 API
User Selection
Overview
§Ability to select Object(s), Point, Edge and Face
§Add new selection to active collection using:
§PickObject()
§PickObjects()
§PickElementsByRectangle()
§PickPoint()
§
§
§
UIDocument uidoc = new UIDocument(document);
Selection choices = uidoc.Selection;
// Choose objects from Revit.
IList<Element> hasPickSome = choices.PickElementsByRectangle("Select by       rectangle");
if (hasPickSome.Count > 0)
{
    int newSelectionCount = choices.Elements.Size;
    string prompt = string.Format("{0} elements added to Selection.",
    newSelectionCount - selectionCount);
    TaskDialog.Show("Revit", prompt);
}
The Selection class has methods for allowing the user to select objects (single or multiple selection) or even a point on screen. This allows the user to select one or more Elements (or other objects, such as an edge or a face) using the cursor and then returns control to your application. These functions do not automatically add the new selection to the active selection collection.

The PickObject() method prompts the user to select an object in the Revit model.
The PickObjects() method prompts the user to select multiple objects in the Revit model.
The PickElementsByRectangle() method prompts the user to select multiple elements using a rectangle, what is often also known as box select.
The PickPoint() method prompts the user to pick a point in the active sketch plane and this returns the XYZ value corresponding to the picked point.

The type of object to be selected is specified when calling PickObject() or PickObjects. Types of objects that can be specified are: Element, PointOnElement, Edge or Face.

We can also add custom status messages to the pick functions prompting users on what needs to be selected or picked. This is done using the StatusbarTip. Each of the Pick functions has an overload that has a String parameter in which a custom status message can be provided.