Select to view content in your preferred language

How to programmatically get project default units

74
2
yesterday
ujr_esrich
New Contributor

Hi Community, is there a way to get at a Pro project's default units programmatically? They can be set in Pro from Backstage > Options > Project > Units (see screenshot). I would have expected these settings to be exposed somewhere on ArcGIS.Desktop.Core.ApplicationOptions, but I can't find it there nor elsewhere. Or is this not exposed at all? A similar question has been asked some years ago but remained unanswered. Any hints are much appreciated.

ujr_esrich_0-1767794321135.png

 

0 Kudos
2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Take a look at the ArcGIS Pro SDK API reference. Code from reference below:

        protected override async void OnClick()
        {
            await QueuedTask.Run(() =>
            {
                var unit_formats = Enum.GetValues(typeof(UnitFormatType))
                                  .OfType<UnitFormatType>().ToList();
                System.Diagnostics.Debug.WriteLine("Default project units\r\n");

                foreach (var unit_format in unit_formats)
                {
                    var default_unit = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat(unit_format);
                    var line = $"{unit_format.ToString()}: {default_unit.DisplayName}, {default_unit.UnitCode}";
                    System.Diagnostics.Debug.WriteLine(line);
                }
                System.Diagnostics.Debug.WriteLine("");
            });


        }

 

 

0 Kudos
CharlesMacleod
Esri Regular Contributor
0 Kudos