- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So in some of my addin code, im exporting data, and this is also relevant for coordinate systems.
Therefore its always important to check what the user has set the units of his project to, else many calculations may fail.
so to make a long story short; up untill revit 2020 i have been using this call:
DisplayUnitType displayUnitsType = commandData.Application.ActiveUIDocument.Document.GetUnits().GetFormatOptions(UnitType.UT_Length).DisplayUnits;
From here on i could simply check if the type set set to DUT_MILLIMETERS so i would be sure the conversion factor would be correct.
Now with the change of API 2021 i am trying to understand this ForgeTyeID.
With "GetFormatOptions" i could paste a ForgeTypeID but this would already be a set unit type (inch/meter/...).
it can no longer check what the user actually has set in the unit settings menu.
Alternatively i tried this new query:
FormatOptions formatoption = commandData.Application.ActiveUIDocument.Document.GetUnits().GetFormatOptions(SpecTypeId.Length);
so now im checking what the user has put in his settings menu for Units in the field for Length.
But here i find it strange to notice that The formatOptions has no exposed parameter to see the units.
yes it has "DisplayUnits" , but this is deprecated...
So im back to the beginning: with this new change in 2021 API, how do i check what the user has set in his units menu? just checking document DisplayUnitSystem is not safe, although its set to METRIC, a user can still just set inches in its units settings.
anyone found a way how to do this now in 2021 in a reliable way?
Solved! Go to Solution.