(Part of our Revit API 2011 Series)
The Revit 2011 API adds some new ways to interact with elements in the project – through picking. These are all available through the UIDocument.Selection class:
- PickObject (replaces PickOne – pick something in the active view – get back a reference)
- PickObjects – pick multiple objects, click “Finish” when done.
- PickElementsByRectangle – a replacement for “WindowSelect”
- PickPoint – return an XYZ coordinate based on picking on the active workplane
What’s Even Better?
All of the above except for PickPoint support a number of options that go deeper than what we had in Revit 2010 and prior (where you could only support picking full elements):
- Element (as before a whole element)
- Face (a specific face of an element)
- Edge (any model edge)
- PointOnElement (any point on any face or curve)
Further, the methods mentioned above also support a new concept as well – a Selection Filter interface: ISelectionFilter. You can implement ISelectionFilter on any class – it will get callbacks from the pick method to help you control what is allowed to be selected or not:
- a Pre-filter method at the element-level
- a Post-filter method at the reference-level
This lets you easily limit your selections to, for example, “walls” or “exterior walls” or “an inside horizontal top edge of an exterior wall” – the mind boggles.
But Wait, There’s More!
While PickPoint() does not support the options described above – it DOES support a different set of options – Object Snaps!
- Points - Snaps to site points.
- Quadrants - Snaps to quadrant points. For arcs, jump snaps are enabled.
- Tangents - Snaps tangent to an arc.
- Perpendicular - Snaps to perpendicular elements or components.
- Centers - Snaps to the center of an arc.
- Intersections - Snaps to intersections.
- WorkPlaneGrid - Snaps to a work plane grid.
- Nearest - Snaps to the nearest element or component.
- Midpoints - Snaps to the midpoint of an element or component.
- Endpoints - Snaps to the endpoint of an element or component.
The Pick mechanism in Revit has gone from paltry to an embarrassment of riches… I’m not aware of a better Pick API in any CAD system. While there are still a few usability oddities, it’s a vast improvement over 2010.