ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / Extend Method
The polyline to be extended.
The polyline to extend to.
The type of extend operation to perform.
Example

In This Topic
    Extend Method (IGeometryEngine)
    In This Topic
    Performs the extend operation on a polyline using a polyline as the extender. The output polyline will have the first and last segment of each part extended to the extender if the segments can be interpolated to intersect the extender. In the case that the segments can be extended to multiple segments of the extender, the shortest extension is chosen. Only end points for parts that are not shared by the end points of other parts will be extended. If the polyline cannot be extended by the input extender, then a null will be returned.
    Syntax

    Parameters

    polyline
    The polyline to be extended.
    extender
    The polyline to extend to.
    extendFlags
    The type of extend operation to perform.

    Return Value

    The extended polyline.
    Exceptions
    ExceptionDescription
    Either polyline or extender or both are null or empty.
    Incompatible spatial references between the input geometries.
    Throws InvalidOperationException if both ExtendFlags.NoEndAttributes and ExtendFlags.KeepEndAttributes flags are sent together.
    Remarks
    Equivalent to IConstructCurve.ConstructExtended
    Example
    Extend a polyline
    // build a polyline
    var polyline = PolylineBuilderEx.CreatePolyline(new[]
    {
      MapPointBuilderEx.CreateMapPoint(1, 1, 10, 20),
      MapPointBuilderEx.CreateMapPoint(0, 0, 10, 20),
      MapPointBuilderEx.CreateMapPoint(1, -1, 10, 20)
    });
    
    // build the extender line
    var extender = PolylineBuilderEx.CreatePolyline(new[]
    {
      MapPointBuilderEx.CreateMapPoint(2, 2),
      MapPointBuilderEx.CreateMapPoint(2, -2),
    });
    
    // extend
    var result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes);
    Polyline extendedLine = result as Polyline;
    // result.Parts[0].Points[0] = 2, 2, 10, 20
    // result.parts[0].Points[1] = 1, 1, 10, 20
    // result.Parts[0].Points[2] = 0, 0, 10, 20
    // result.Parts[0].Points[3] = 1, -1, 10, 20
    // result.Parts[0].Points[4] = 2, -2, 10, 20
    
    // change the flags
    result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.NoEndAttributes);
    extendedLine = result as Polyline;
    // result.Parts[0].Points[0] = 2, 2, 0
    // result.parts[0].Points[1] = 1, 1, 10, 20
    // result.Parts[0].Points[2] = 0, 0, 10, 20
    // result.Parts[0].Points[3] = 1, -1, 10, 20
    // result.Parts[0].Points[4] = 2, -2, 0
    
    // extend
    result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes | ExtendFlags.NoExtendAtTo);
    extendedLine = result as Polyline;
    // result.Parts[0].Points[0] = 2, 2, 10, 20
    // result.parts[0].Points[1] = 1, 1, 10, 20
    // result.Parts[0].Points[2] = 0, 0, 10, 20
    // result.Parts[0].Points[3] = 1, -1, 10, 20
    
    // extend with no intersection 
    
    polyline = PolylineBuilderEx.CreatePolyline(new[]
    {
      MapPointBuilderEx.CreateMapPoint(1, 1),
      MapPointBuilderEx.CreateMapPoint(3, 1)
    });
    
    extender = PolylineBuilderEx.CreatePolyline(new[]
    {
      MapPointBuilderEx.CreateMapPoint(1, 4),
      MapPointBuilderEx.CreateMapPoint(3, 4)
    });
    
    result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.Default);
    // result = null
    
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also