ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Core.UnitFormats Namespace / IDisplayUnitFormats Interface / SetDefaultProjectUnitFormat Method
Example

In This Topic
    SetDefaultProjectUnitFormat Method (IDisplayUnitFormats)
    In This Topic
    Set the given project default unit format in the current project.
    Syntax
    void SetDefaultProjectUnitFormat( 
       DisplayUnitFormat defaultFormat
    )
    Sub SetDefaultProjectUnitFormat( _
       ByVal defaultFormat As DisplayUnitFormat _
    ) 

    Parameters

    defaultFormat
    Example
    Set the Defaults for the Project Unit Formats
    //Must be on the QueuedTask.Run()
    
    var unit_formats = Enum.GetValues(typeof(UnitFormatType)).OfType<UnitFormatType>().ToList();
    foreach (var unit_type in unit_formats)
    {
      var current_default = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat(unit_type);
      //Arbitrarily pick the last unit in each unit format list
      var replacement = DisplayUnitFormats.Instance.GetProjectUnitFormats(unit_type).Last();
      DisplayUnitFormats.Instance.SetDefaultProjectUnitFormat(replacement);
    
      var line = $"{current_default.DisplayName}, {current_default.UnitName}, {current_default.UnitCode}";
      var line2 = $"{replacement.DisplayName}, {replacement.UnitName}, {replacement.UnitCode}";
    
      System.Diagnostics.Debug.WriteLine($"Format: {unit_type.ToString()}");
      System.Diagnostics.Debug.WriteLine($" Current default: {line}");
      System.Diagnostics.Debug.WriteLine($" Replacement default: {line2}");
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also