ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Map Class / GetElevationUnitFormat Method
Example

In This Topic
    GetElevationUnitFormat Method
    In This Topic
    Gets the current scene elevation unit format. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    The elevation unit format is used to format the units used by the coordinate system display at the bottom of the scene that shows elevation as well as format the scale combo box.
    Calling GetElevationUnitFormat on anything other than a scene will return the default project distance unit format.
    Example
    Get the Current Map Elevation Unit
    //var map = MapView.Active.Map;
    //Must be on the QueuedTask.Run()
    
    //If the map is not a scene, the default Project distance
    //unit will be returned
    var elev_unit = map.GetElevationUnitFormat();
    var line = $"{elev_unit.DisplayName}, {elev_unit.UnitCode}";
    System.Diagnostics.Debug.WriteLine(line);
    
    Format an Elevation Using the Current Map Elevation Unit
    var mv = MapView.Active;
    var map = mv.Map;
    
    QueuedTask.Run(() =>
    {
      //Get the current elevation unit. If the map is not
      //a scene the default Project distance unit is returned
      var elev_unit = map.GetElevationUnitFormat();
    
      //Format the view camera elevation
      var str = elev_unit.FormatValue(mv.Camera.Z);
    
      System.Diagnostics.Debug.WriteLine($"Formatted elevation: {str}");
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also