BuildingCoder.Creator.NewSketchPlaneContainCurve C# (CSharp) Method

NewSketchPlaneContainCurve() private method

Return a new sketch plane containing the given curve. Update, later: please note that the Revit API provides an overload of the NewPlane method taking a CurveArray argument, which could presumably be used instead.
private NewSketchPlaneContainCurve ( Curve curve ) : SketchPlane
curve Curve
return SketchPlane
        SketchPlane NewSketchPlaneContainCurve(
            Curve curve)
        {
            XYZ p = curve.GetEndPoint( 0 );
              XYZ normal = GetCurveNormal( curve );

              //Plane plane = _creapp.NewPlane( normal, p ); // 2016
              Plane plane = Plane.CreateByNormalAndOrigin( normal, p ); // 2017

            #if DEBUG
              if( !( curve is Line ) )
              {
            //CurveArray a = _creapp.NewCurveArray();
            //a.Append( curve );
            //Plane plane2 = _creapp.NewPlane( a ); // 2016

            List<Curve> a = new List<Curve>( 1 );
            a.Add( curve );
            CurveLoop b = CurveLoop.Create( a );
            Plane plane2 = b.GetPlane(); // 2017

            Debug.Assert( Util.IsParallel( plane2.Normal,
              plane.Normal ), "expected equal planes" );

            Debug.Assert( Util.IsZero( plane2.SignedDistanceTo(
              plane.Origin ) ), "expected equal planes" );
              }
            #endif // DEBUG

              //return _credoc.NewSketchPlane( plane ); // 2013

              return SketchPlane.Create( _doc, plane ); // 2014
        }