ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / SetMsAsDistance Method / SetMsAsDistance(Polyline,Coordinate2D,Double,Double,Boolean) Method
The polyline in which to set the M-values.
Determines whether to start measuring distance from the start or end of the polyline part. Measurement starts at the start or end point that is closest to origin.
The value by which the cumulative length of the polyline is multiplied.
The value that is added to the scaled cumulative length of the polyline.
Determines whether distances between parts of the polyline should be ignored or not.
Example

In This Topic
    SetMsAsDistance(Polyline,Coordinate2D,Double,Double,Boolean) Method
    In This Topic
    Sets the M-values of the vertices as scaled and offset distances measured along the polyline.
    Syntax
    Overloads Function SetMsAsDistance( _
       ByVal polyline As Polyline, _
       ByVal origin As Coordinate2D, _
       ByVal scale As Double, _
       ByVal offset As Double, _
       ByVal ignoreGaps As Boolean _
    ) As Polyline

    Parameters

    polyline
    The polyline in which to set the M-values.
    origin
    Determines whether to start measuring distance from the start or end of the polyline part. Measurement starts at the start or end point that is closest to origin.
    scale
    The value by which the cumulative length of the polyline is multiplied.
    offset
    The value that is added to the scaled cumulative length of the polyline.
    ignoreGaps
    Determines whether distances between parts of the polyline should be ignored or not.

    Return Value

    Polyline with M-values set. If the input polyline is empty, then it is returned unchanged.
    Exceptions
    ExceptionDescription
    The input polyline is null.
    The geometry is not M-Aware.
    The x-value or y-value of the origin is NaN.
    Example
    Set the M-values of the vertices as scaled and offset distances measured along a polyline - SetMsAsDistance
    string json = "{\"hasM\":true,\"paths\":[[[0,0,1],[3,0,2],[3,6,3],[7,6,4]]],\"spatialReference\":{\"wkid\":4326}}";
    Polyline polyline = PolylineBuilderEx.FromJson(json);
    Coordinate2D origin = new Coordinate2D(0, 0);
          
    Polyline outputPolyline = GeometryEngine.Instance.SetMsAsDistance(polyline, origin, 0.5, 1, true) as Polyline;
    // The xy-coordinates of the polyline don't change.
    // The points of outputPolyline are (x, y, m): 
    // (0, 0, 1), (3, 0, 2.5), (3, 6, 5.5), (7, 6, 7.5)
    
    // Measurements will start at the end of the polyline, point (7, 6)
    origin = new Coordinate2D(4, 6);
    
    outputPolyline = GeometryEngine.Instance.SetMsAsDistance(polyline, origin, 0.5, 1, true) as Polyline;
    // The points of outputPolyline are (x, y, m): 
    // (0, 0, 7.5), (3, 0, 6), (3, 6, 3), (7, 6, 1)
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.3 or higher.
    See Also