ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / SetMsAsDistance Method
The multipart in which to set the M values.
Indicates whether the M-values are set as lengths or ratios along the multipart.
Example

In This Topic
    SetMsAsDistance Method (GeometryEngine)
    In This Topic
    Sets the M values to the cumulative length from the start of the multipart.
    Syntax
    Public Function SetMsAsDistance( _
       ByVal multipart As Multipart, _
       ByVal asRatioOrLength As AsRatioOrLength _
    ) As Multipart

    Parameters

    multipart
    The multipart in which to set the M values.
    asRatioOrLength
    Indicates whether the M-values are set as lengths or ratios along the multipart.

    Return Value

    Multipart with M-values set. If the input multipart is empty, then it is returned unchanged.
    Exceptions
    ExceptionDescription
    Multipart is null.
    This geometry is not M-Aware.
    Spatial reference of multipartis an image coordinate system.
    Example
    Set M values to the cumulative length from the start of the multipart - SetMsAsDistance
    string json = "{\"hasM\":true,\"rings\":[[[0,0],[0,3000],[4000,3000],[4000,0],[0,0]]],\"spatialReference\":{\"wkid\":3857}}";
    Polygon polygon = PolygonBuilderEx.FromJson(json);
    
    Polygon outPolygon = GeometryEngine.Instance.SetMsAsDistance(polygon, AsRatioOrLength.AsLength) as Polygon;
    ReadOnlyPointCollection outPoints = outPolygon.Points;
    // outPoints M values are { 0, 3000, 7000, 10000, 14000 };
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also