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.
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("");
});
}