BuildingCoder.CmdPickPoint3d.PickFaceSetWorkPlaneAndPickPoint C# (CSharp) Метод

PickFaceSetWorkPlaneAndPickPoint() приватный Метод

Prompt the user to select a face on an element and then pick a point on that face. The first picking of the face on the element temporarily redefines the active work plane, on which the second point can be picked.
private PickFaceSetWorkPlaneAndPickPoint ( UIDocument uidoc, XYZ &point_in_3d ) : bool
uidoc UIDocument
point_in_3d XYZ
Результат bool
        bool PickFaceSetWorkPlaneAndPickPoint(
            UIDocument uidoc,
            out XYZ point_in_3d)
        {
            point_in_3d = null;

              Document doc = uidoc.Document;

              try
              {
            Reference r = uidoc.Selection.PickObject(
              ObjectType.Face,
              "Please select a planar face to define work plane" );

            Element e = doc.GetElement( r.ElementId );

            if( null != e )
            {
              PlanarFace face
            = e.GetGeometryObjectFromReference( r )
              as PlanarFace;

              if( face != null )
              {
            //Plane plane = new Plane( face.FaceNormal, face.Origin ); // 2016
            Plane plane = Plane.CreateByNormalAndOrigin(
              face.FaceNormal, face.Origin ); // 2017

            using( Transaction t = new Transaction( doc ) )
            {
              t.Start( "Temporarily set work plane"
                + " to pick point in 3D" );

              //SketchPlane sp = doc.Create.NewSketchPlane( plane ); // 2013

              SketchPlane sp = SketchPlane.Create( doc, plane ); // 2014

              uidoc.ActiveView.SketchPlane = sp;
              uidoc.ActiveView.ShowActiveWorkPlane();

              point_in_3d = uidoc.Selection.PickPoint(
                "Please pick a point on the plane"
                + " defined by the selected face" );

              t.RollBack();
            }
              }
            }
              }
              catch( Autodesk.Revit.Exceptions.OperationCanceledException )
              {
              }

              return null != point_in_3d;
        }