ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / SetMsAsDistance Method / SetMsAsDistance(Multipart,AsRatioOrLength) 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 Version

SetMsAsDistance(Multipart,AsRatioOrLength) Method
Sets the M-values to the cumulative length from the start of the multipart.
Syntax

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.
Example
Set the M-values to the cumulative length of the start of the multipart - SetMsAtDistance
string json = "{\"hasM\":true,\"paths\":[[[-3000,-2000,1],[-2000,-2000,2],[-1000,-2000,3],[0,-2000,null],[1000,-2000,4],[2000,-2000,5],[3000,-2000,10],[4000,-2000,11],[5000,-2000,12],[6000,-2000,13],[7000,-2000,14]]],\"spatialReference\":{\"wkid\":3857}}";
Polyline polyline = PolylineBuilderEx.FromJson(json);

Polyline outPolyline = GeometryEngine.Instance.SetMsAsDistance(polyline, AsRatioOrLength.AsLength) as Polyline;
// The xy-coordinates don't change. 
// The M-values of the vertices in outPolyline are (x, y, m): 
// { 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000 }

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;
// The M-values of the vertices in outPolygon are (x, y, m): { 0, 3000, 7000, 10000, 14000 };
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3.3 or higher.
See Also