Hello to all!
I am new to this forum and to have a simple Problem.
sorry for my bad english
i want select picture as a unit other than Pixel, but i can't
my code is :
var docRef = app.activeDocument;
app.preferences.rulerUnits = Units.CM;
app.preferences.Units = Units.CM;
var x = docRef.height ;
var x = new UnitValue( docRef.height,'CM');
docRef.selection.select(new Array (new Array(0,0),new Array(50,0), new Array(50,x), new Array(0,x)),
SelectionType.REPLACE, 0.0, false);
x value & type is CM But Selection is base of Pixel values
what is wrong !
Selection Unit Problem
Selection Unit Problem
Some/most APIs require pixels. You will have to do the unit conversions yourself in this case.
Selection Unit Problem
Yes unitValues don't work everywhere. Selection still expects Number as pixels. You could do something like this if you want to work with cm.
Code: Select allvar docRef = app.activeDocument;
app.preferences.rulerUnits = Units.CM;
app.preferences.Units = Units.CM;
var x = docRef.height ;// already a unitValue
var zero = new UnitValue( 0,'CM');
var fifty = new UnitValue(50,'cm');
docRef.selection.select([[zero.as('px'),zero.as('px')],[fifty.as('px'),zero], [fifty.as('px'),x.as('px')], [zero,x.as('px')]],SelectionType.REPLACE, 0.0, false);
Code: Select allvar docRef = app.activeDocument;
app.preferences.rulerUnits = Units.CM;
app.preferences.Units = Units.CM;
var x = docRef.height ;// already a unitValue
var zero = new UnitValue( 0,'CM');
var fifty = new UnitValue(50,'cm');
docRef.selection.select([[zero.as('px'),zero.as('px')],[fifty.as('px'),zero], [fifty.as('px'),x.as('px')], [zero,x.as('px')]],SelectionType.REPLACE, 0.0, false);