This document is archived and information here might be outdated.  Recommended version.


Set Z Value on Point Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Set Z Value on Point Snippet

Set a point's ZAware to true and assign it a Z value.

[C#]
///<summary>Set a point's ZAware to true and assign it a Z value.</summary>
///  
///<param name="point">An IPoint interface that is the point to enable Z values.</param>
///<param name="zValue">A System.Double that is the points Z value in map units.</param>
///   
///<remarks></remarks>
public void SetZValueOnPoint(ESRI.ArcGIS.Geometry.IPoint point, System.Double zValue)
{
  if(point == null || point.IsEmpty)
  {
    return;
  }
 
  ESRI.ArcGIS.Geometry.IZAware zAware=(ESRI.ArcGIS.Geometry.IZAware)(point); // Explicit Cast
  zAware.ZAware=true;
  point.Z=zValue;
}
[Visual Basic .NET]
'''<summary>Set a point's ZAware to true and assign it a Z value.</summary>
'''  
'''<param name="point">An IPoint interface that is the point to enable Z values.</param>
'''<param name="zValue">A System.Double that is the points Z value in map units.</param>
'''   
'''<remarks></remarks>
Public Sub SetZValueOnPoint(ByVal point As ESRI.ArcGIS.Geometry.IPoint, ByVal zValue As System.Double)

  If point Is Nothing OrElse point.IsEmpty Then
    Return
  End If

  Dim zAware As ESRI.ArcGIS.Geometry.IZAware=CType(point, ESRI.ArcGIS.Geometry.IZAware) ' Explicit Cast
  zAware.ZAware=True
  point.Z=zValue

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Geometry
  • ESRI.ArcGIS.System