[ExtendScript] Cannot set Document.rulerUnits
There is no way via scripting to set a document's rulerUnits (pts, mm, inch, etc) because the property Document.rulerUnits is—erroneously, surely—read only.
If Document.rulerUnits was writable, we would simply do this:
var doc = app.activeDocument;
doc.rulerUnits = RulerUnits.MILLIMETERS;
This is important because there is literally no way to set this via script, except to create a new document.

-
Sergey Osokin commented
From Object Model Viewer:
<classdef name="Document" dynamic="true">
<property name="rulerUnits" rwaccess="readonly"> -
Sergey Osokin commented
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.