What am I doing
Using the javascript API of the Adobe Photoshop CC 2018 scripting engine:
app.preferences.rulerUnits = Units.MM;
app.preferences.typeUnits = TypeUnits.MM;
app.activeDocument.selection.select([
[0,0],
[0, UnitValue(150, "mm")],
[UnitValue(150, "mm"), UnitValue(150, "mm")],
[UnitValue(150, "mm"), 0]
]);
What am I expecting to happen?
Photoshop creates a selection of 15×15 cm positioned at the top left.
What is actually happening?
Photoshop creates a selection of 12.7×12.7 pixels? positioned I'm not even sure where exactly.
The document's size is 29.7×29.7 cm, so the selection is expected to take half of the artboard. Moreover, the "marching ants" aren't even set to the top left corner of the artboard.
I read most of the referrence plus tried to Google a lot, but the results I'm getting are misleading
UPDATE may not be in pixels after all because UnitValue(150, 'mm').as('px')
outputs 425.196850393701
and not 12.7
which I believed to be the pixels value.
UPDATE tried setting the PPI to 300 to match the document's, according to this answer, but getting the same behaviour.
var startUnit=UnitValue(150, "mm");
startUnit.baseValue = UnitValue(1 / 300, "in");