/// <summary>
        /// Selection with planar face.
        /// See the bottom of the page to see the selection filter implementation.
        /// </summary>
        public void PickPlanarFace()
        {
            // To call ISelectionFilter.AllowReference, use this.
            // This will limit picked face to be planar.
            Document doc = _uiDoc.Document;
            SelectionFilterPlanarFace selFilterPlanarFace = new SelectionFilterPlanarFace(doc);
            Reference r = _uiDoc.Selection.PickObject(ObjectType.Face, selFilterPlanarFace, "Select a planar face");
            Element   e = doc.GetElement(r);
            //Face oFace = r.GeometryObject as Face; // 2011
            Face oFace = e.GetGeometryObjectFromReference(r) as Face; // 2012

            string msg = (null == oFace)
        ? "No face picked."
        : "You picked a face on element " + e.Id.ToString();

            TaskDialog.Show("PickPlanarFace", msg);
        }
        /// <summary>
        /// Selection with planar face. 
        /// See the bottom of the page to see the selection filter implementation. 
        /// </summary>
        public void PickPlanarFace()
        {
            // To call ISelectionFilter.AllowReference, use this.
              // This will limit picked face to be planar.
              Document doc = _uiDoc.Document;
              SelectionFilterPlanarFace selFilterPlanarFace = new SelectionFilterPlanarFace(doc);
              Reference r = _uiDoc.Selection.PickObject(ObjectType.Face, selFilterPlanarFace, "Select a planar face");
              Element e = doc.GetElement(r);
              //Face oFace = r.GeometryObject as Face; // 2011
              Face oFace = e.GetGeometryObjectFromReference(r) as Face; // 2012

              string msg = (null == oFace)
            ? "No face picked."
            : "You picked a face on element " + e.Id.ToString();

              TaskDialog.Show("PickPlanarFace", msg);
        }