Access to the `UnitValue` api/method in UXP Adobe InDesign

ExtendScript for Adobe InDesign had an api/method called UnitValue().
Some documentation of it is here:

I had used it in some legacy code like this:

		var downUnitsToMove = String(new UnitValue(down, unit));
		var rightUnitsToMove = String(new UnitValue(right, unit));

I can’t seem to locate this in UXP. Anybody know the proper syntax or does it no longer exist?


I think this is defined at ExtendScript level, along with things like the XML object and not part of the InDesign DOM API.

You could do a doScript into ExtendScript, create an instance there and return the string.

IMO looking purely from a API perspective the UXP side of things is quite a downgrade to ExtendScript, it is slower and misses very useful/needed features that were part of ExtendScript for ages (resolving specifiers, persistent engine, global helper objects).

Thankfully the doscript is available with the option to do (serious) stuff in ExtendScript still from a UXP plugin. Best of both worlds I suppose…

1 Like

I am using math.js. It is useful not only for unit conversions, but also for calculating expressions.

1 Like