ArcGIS Pro 2.7 API Reference Guide
Distance3D Method (GeometryEngine)
Example 

ArcGIS.Core.Geometry Namespace > GeometryEngine Class : Distance3D Method
The first geometry.
The second geometry.
Measures the 3-dimensional planar distance between two geometries.
Syntax
public double Distance3D( 
   Geometry geometry1,
   Geometry geometry2
)
Public Function Distance3D( _
   ByVal geometry1 As Geometry, _
   ByVal geometry2 As Geometry _
) As Double

Parameters

geometry1
The first geometry.
geometry2
The second geometry.

Return Value

The distance between the two input geometries in the same unit as the spatial reference of the input geometries.
Exceptions
ExceptionDescription
Either geometry1 or geometry2 or both are null or empty.
The method is not implemented for GeometryBag.
Incompatible spatial references between the input geometries.
Either geometry1 or geometry2 is not Z-Aware.
Remarks
Returns the minimum distance between two z-aware geometries in 3D space. If the geometries intersect, the minimum distance is 0. Only returns the distance, not the nearest points.
Example
// between points 
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1, 1, 1);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(2, 2, 2);
MapPoint pt3 = MapPointBuilder.CreateMapPoint(10, 2, 1);

// pt1 to pt2
double d = GeometryEngine.Instance.Distance3D(pt1, pt2);        // d = Math.Sqrt(3)

// pt1 to pt3
d = GeometryEngine.Instance.Distance3D(pt1, pt3);        // d = Math.Sqrt(82)

// pt2 to pt3
d = GeometryEngine.Instance.Distance3D(pt2, pt3);        // d = Math.Sqrt(65)

// intersecting lines

List<MapPoint> list = new List<MapPoint>();
list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 1.0));
list.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0, 1.0));
list.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0, 1.0));

Polyline line1 = PolylineBuilder.CreatePolyline(list);

List<MapPoint> list2 = new List<MapPoint>();
list2.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0, 1.0));
list2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0, 1.0));
list2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0, 1.0));

Polyline line2 = PolylineBuilder.CreatePolyline(list2);

bool intersects = GeometryEngine.Instance.Intersects(line1, line2);    // intersects = true
d = GeometryEngine.Instance.Distance3D(line1, line2);                  // d = 0   (distance is 0 when geomtries intersect)
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

GeometryEngine Class
GeometryEngine Members