ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Core.UnitFormats Namespace / IDisplayUnitFormats Interface / GetPredefinedProjectUnitFormats Method
Example

In This Topic
    GetPredefinedProjectUnitFormats Method (IDisplayUnitFormats)
    In This Topic
    Gets the complete list of available unit formats for the given UnitFormatType
    Syntax
    IList<DisplayUnitFormat> GetPredefinedProjectUnitFormats( 
       UnitFormatType unitFormat
    )
    Function GetPredefinedProjectUnitFormats( _
       ByVal unitFormat As UnitFormatType _
    ) As IList(Of DisplayUnitFormat)

    Parameters

    unitFormat

    Return Value

    Example
    Get The Full List of All Available Unit Formats
    //Must be on the QueuedTask.Run()
    
    var unit_formats = Enum.GetValues(typeof(UnitFormatType))
                          .OfType<UnitFormatType>().ToList();
    System.Diagnostics.Debug.WriteLine("All available units\r\n");
    
    foreach (var unit_format in unit_formats)
    {
      var units = DisplayUnitFormats.Instance.GetPredefinedProjectUnitFormats(unit_format);
      System.Diagnostics.Debug.WriteLine(unit_format.ToString());
    
      foreach (var display_unit_format in units)
      {
        var line = $"{display_unit_format.DisplayName}, {display_unit_format.UnitCode}";
        System.Diagnostics.Debug.WriteLine(line);
      }
      System.Diagnostics.Debug.WriteLine("");
    }
    Set a Specific List of Unit Formats for the Current Project
    //Must be on the QueuedTask.Run()
    
    //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, 
    //UnitFormatType.Direction, UnitFormatType.Location
    
    //Get the full list of all available location units
    var all_units = DisplayUnitFormats.Instance.GetPredefinedProjectUnitFormats(
                                                          UnitFormatType.Location);
    //keep units with an even factory code
    var list_units = all_units.Where(du => du.UnitCode % 2 == 0).ToList();
    
    //set them as the new location unit collection. A new default is not being specified...
    DisplayUnitFormats.Instance.SetProjectUnitFormats(list_units);
    
    //set them as the new location unit collection along with a new default
    DisplayUnitFormats.Instance.SetProjectUnitFormats(
                                            list_units, list_units.First());
    
    //Note: UnitFormatType.Page, UnitFormatType.Symbol2D, UnitFormatType.Symbol3D
    //cannot be set.
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also