Change units in an open document
For an active document, we can get the key value of the ruler units through the app.activeDocument.rulerUnits property.
We can also create a new document with the desired units:
var docPreset = new DocumentPreset;
docPreset.units = RulerUnits.Centimeters;
var newDoc = app.documents.addDocument("Web", docPreset);
And can we switch to other ruler units in the document? NO! Because the app.activeDocument.rulerUnits property is read-only, not read/write.
And it's not logical. So it just needs to be linked to the Document Setup > Units dialog mechanism.
In Adobe Community or direct messages comes from users asking how to change units of measure. I came up with a very bad way, suitable for Windows OS, to open Document Setup and emulate keystrokes in dropdown units via VBScript. It doesn't have to be this way, it's a bad workaround.
-
Sergey Osokin commented
From Object Model Viewer:
<classdef name="Document" dynamic="true">
<property name="rulerUnits" rwaccess="readonly">