ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Geometry Namespace / LineBuilderEx Class / ToSegment Method
Example

In This Topic
    ToSegment Method (LineBuilderEx)
    In This Topic
    Returns a LineSegment instance representing the current state of the builder.
    Syntax
    Public Shadows Function ToSegment() As LineSegment
    public new LineSegment ToSegment()

    Return Value

    Example
    Construct a LineSegment using two MapPoints
    {
      // Use a builderEx convenience method or use a builderEx constructor.
    
      MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0);
      MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0);
    
      // BuilderEx convenience methods don't need to run on the MCT.
      LineSegment lineFromMapPoint = LineBuilderEx.CreateLineSegment(startPt, endPt);
    
      // coordinate2D
      Coordinate2D start2d = (Coordinate2D)startPt;
      Coordinate2D end2d = (Coordinate2D)endPt;
    
      LineSegment lineFromCoordinate2D = LineBuilderEx.CreateLineSegment(start2d, end2d);
    
      // coordinate3D
      Coordinate3D start3d = (Coordinate3D)startPt;
      Coordinate3D end3d = (Coordinate3D)endPt;
    
      LineSegment lineFromCoordinate3D = LineBuilderEx.CreateLineSegment(start3d, end3d);
    
      // lineSegment
      LineSegment anotherLineFromLineSegment = LineBuilderEx.CreateLineSegment(lineFromCoordinate3D);
    
    
      // builderEx constructors don't need to run on the MCT
      LineBuilderEx lbEx = new LineBuilderEx(startPt, endPt);
      lineFromMapPoint = lbEx.ToSegment() as LineSegment;
    
      lbEx = new LineBuilderEx(start2d, end2d);
      lineFromCoordinate2D = lbEx.ToSegment() as LineSegment;
    
      lbEx = new LineBuilderEx(start3d, end3d);
      lineFromCoordinate3D = lbEx.ToSegment() as LineSegment;
    
      lbEx = new LineBuilderEx(startPt, endPt);
      lineFromMapPoint = lbEx.ToSegment() as LineSegment;
    
      lbEx = new LineBuilderEx(lineFromCoordinate3D);
      anotherLineFromLineSegment = lbEx.ToSegment() as LineSegment;
    }
    Alter LineSegment Coordinates
    {
      MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0);
      MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0);
      // builderEx constructors don't need to run on the MCT
      LineBuilderEx lbuilderEx = new LineBuilderEx(lineSegment);
      // find the existing coordinates
      lbuilderEx.QueryCoords(out startPt, out endPt);
    
      // or use 
      //startPt = lbuilderEx.StartPoint;
      //endPt = lbuilderEx.EndPoint;
    
      // update the coordinates
      lbuilderEx.SetCoords(GeometryEngine.Instance.Move(startPt, 10, 10) as MapPoint, GeometryEngine.Instance.Move(endPt, -10, -10) as MapPoint);
    
      // or use 
      //lbuilderEx.StartPoint = GeometryEngine.Instance.Move(startPt, 10, 10) as MapPoint;
      //lbuilderEx.EndPoint = GeometryEngine.Instance.Move(endPt, -10, -10) as MapPoint;
    
      LineSegment segment2 = lbuilderEx.ToSegment() as LineSegment;
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also