ArcGIS Pro 2.8 API Reference Guide
SetConstantZ Method (GeometryEngine)
Example 

ArcGIS.Core.Geometry Namespace > GeometryEngine Class : SetConstantZ Method
The polygon or polyline to replace Zs.
The Z value to assign.
Replaces each Z value on the geometry with the specified Z value.
Syntax
public Multipart SetConstantZ( 
   Multipart multipart,
   double zValue
)
Public Function SetConstantZ( _
   ByVal multipart As Multipart, _
   ByVal zValue As Double _
) As Multipart

Parameters

multipart
The polygon or polyline to replace Zs.
zValue
The Z value to assign.

Return Value

A geometry in which each coordinate has the specified Z value.
Exceptions
ExceptionDescription
Multipart is null or empty.
This geometry is not Z-Aware.
Example
List<Coordinate3D> coordsZ = new List<Coordinate3D>()
{
  new Coordinate3D(1, 2, 3),
  new Coordinate3D(4, 5, 6),
  new Coordinate3D(7, 8, double.NaN)
};

Polyline polyline = PolylineBuilder.CreatePolyline(coordsZ);
// polyline.HasZ = true

Polyline polylineSetZ = GeometryEngine.Instance.SetConstantZ(polyline, -1) as Polyline;
// polylineSetZ.Points[0].Z = -1
// polylineSetZ.Points[1].Z = -1
// polylineSetZ.Points[2].Z = -1

polylineSetZ = GeometryEngine.Instance.SetConstantZ(polyline, double.NaN) as Polyline;
// polyline.HasZ = true
// polylineSetZ.Points[0].HasZ = true
// polylineSetZ.Points[0].Z = NaN
// polylineSetZ.Points[1].HasZ = true
// polylineSetZ.Points[1].Z = NaN
// polylineSetZ.Points[2].HasZ = true
// polylineSetZ.Points[2].Z = NaN

polylineSetZ = GeometryEngine.Instance.SetConstantZ(polyline, double.PositiveInfinity) as Polyline;
// polyline.HasZ = true
// polylineSetZ.Points[0].HasZ = true
// polylineSetZ.Points[0].Z = double.PositiveInfinity
// polylineSetZ.Points[1].HasZ = true
// polylineSetZ.Points[1].Z = double.PositiveInfinity
// polylineSetZ.Points[2].HasZ = true
// polylineSetZ.Points[2].Z = double.PositiveInfinity
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

GeometryEngine Class
GeometryEngine Members