Revit.SDK.Samples.CurtainWallGrid.CS.GridDrawing.ConvertToLine2D C# (CSharp) Method

ConvertToLine2D() private method

convert the grid line in CurtainGridLine format to GridLine2D format in the Canvas area, the "System.Drawing.Point" instances are directly used, it's hard for us to use CurtainGridLine and Autodesk.Revit.DB.XYZ directly, so convert them to 2D data first
private ConvertToLine2D ( CurtainGridLine line, List segPaths, int gridLineIndex ) : GridLine2D
line CurtainGridLine /// the grid line in CurtainGridLine format ///
segPaths List /// the grid line in GraphicsPath format (the GraphicsPath contains the grid line in GridLine2D format) ///
gridLineIndex int /// the index of the grid line ///
return GridLine2D
        private GridLine2D ConvertToLine2D(CurtainGridLine line, List<GraphicsPath> segPaths, int gridLineIndex)
        {
            Curve curve = line.FullCurve;
             Autodesk.Revit.DB.XYZ point1 = curve.get_EndPoint(0);
             Autodesk.Revit.DB.XYZ point2 = curve.get_EndPoint(1);

             Vector4 v1 = new Vector4(point1);
             Vector4 v2 = new Vector4(point2);

             // transform from 3D point to 2D point
             v1 = m_coordinates.TransformMatrix.Transform(v1);
             v2 = m_coordinates.TransformMatrix.Transform(v2);

             // create a new line in GridLine2D format
             GridLine2D line2D = new GridLine2D();
             line2D.StartPoint = new System.Drawing.Point((int)v1.X, (int)v1.Y);
             line2D.EndPoint = new System.Drawing.Point((int)v2.X, (int)v2.Y);
             line2D.Locked = line.Lock;
             line2D.IsUGridLine = line.IsUGridLine;
             // get which segments are skipped
             List<SegmentLine2D> skippedSegments = ConvertCurveToSegment(line.SkippedSegmentCurves);
             // get all the segments for the curtain grid (and tag the skipped ones out)
             GetSegments(line2D, line.AllSegmentCurves, skippedSegments, segPaths, gridLineIndex);
             return line2D;
        }