ArcGIS Pro 3.7 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
    Sub SetDefaultProjectUnitFormat( _
       ByVal defaultFormat As DisplayUnitFormat _
    ) 
    void SetDefaultProjectUnitFormat( 
       DisplayUnitFormat defaultFormat
    )

    Parameters

    defaultFormat
    Example
    Set the Defaults for the Project Unit Formats
    {
      // Note: 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}");
        System.Diagnostics.Debug.WriteLine($" Current default: {line}");
        System.Diagnostics.Debug.WriteLine($" Replacement default: {line2}");
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also