Changing Units in "Units Manager" from Code

In Commands > Gateway, there exists a tool called, "Units Manager", where you can switch between different units which are available. This (understandably) changes how the measure tool behaves, giving you either millimeters or inches, depending on your current units.

I would like to be able to read these particular settings from code, specifically the "Preferred Data Entry Units" and "Object Information Units" so that I can know what my units are currently set to.

As far as I am aware, these are independent of any Part units, I believe they are tied to either the current session or user settings.

NX Version 2206.

Any help is appreciated.

Units Manager

Update: I figured it out. In case anyone else needs to know:

{Session reference}.Parts.Display.UnitCollection.GetDefaultDataEntryUnits()

This will return whatever UnitCollection.UnitDefaults your session is using.