ArcGIS Pro 3.7 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
    Function GetPredefinedProjectUnitFormats( _
       ByVal unitFormat As UnitFormatType _
    ) As IList(Of DisplayUnitFormat)
    IList<DisplayUnitFormat> GetPredefinedProjectUnitFormats( 
       UnitFormatType unitFormat
    )

    Parameters

    unitFormat

    Return Value

    Example
    Get The Full List of All Available Unit Formats
    {
      //Note: 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
    {
      // Note: 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 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also