Copy link to clipboard
Copied
Hey Guys!
I have some extensions that measure the width and height...
but if the
Edit menu>> preferences >> units are in centimeter
the result of the measurement will be faaaarrr different than in pixels
like:
43 in cm
500000 in pixels...
is there any option for getting the units type or setting it permanently or temporarly?!?
I found this one but it didnt do anything:
app.scriptPreference.measurementUnit = app.MeasurementUnits.PIXELS;
any help would be appreciated!!
Thanks!!
Ben
app.preferences.rulerUnits = Units.PIXELS;//sets the units to pixels
var whatUnits = app.preferences.rulerUnits;//gets whatever the current units are.
Copy link to clipboard
Copied
app.preferences.rulerUnits
Copy link to clipboard
Copied
Thanks Xbytor2!
Could You please provide some additional info >> this code is get or set?!?
how to set to pixel or how to get it into a variable or smthg..
please add 1-2 example. many thanks!
Ben
Copy link to clipboard
Copied
app.preferences.rulerUnits = Units.PIXELS;//sets the units to pixels
var whatUnits = app.preferences.rulerUnits;//gets whatever the current units are.
Copy link to clipboard
Copied
Bonjour
Try this :
#target photoshop
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
//Passage en mm
app.preferences.typeUnits = TypeUnits.MM //MM et non CM
app.preferences.rulerUnits = Units.CM //ou MM
app.displayDialogs = DialogModes.NO
alert( app.activeDocument.width )
//Retour aux reglages d origine
app.preferences.rulerUnits = startRulerUnits
app.preferences.typeUnits = startTypeUnits
Copy link to clipboard
Copied
Dominique, Chuck, Xbytor2 Many thanks... after this it was a piece of cake!
Ben
Copy link to clipboard
Copied
okay one ore question!!!
how do you get info like this ?!? 🙂
i tried to search in the js reference guide ... but didnt find anything...
"we simply know" is not an answer!!! 😄
Copy link to clipboard
Copied
Info like what?
Copy link to clipboard
Copied
info like how do you get or set the units etc. 🙂 (the purpose is>> if you can point to a source, method... my life would be easier 🙂
(as i see. Many things that You know here, not represent in the script ref guides (i have more than one)
Just wondering where/how do You know than! ?
Copy link to clipboard
Copied
The "Photoshop Scriptref.pdf" has sample scripts. You can also look at scripts that come with PS for how things are done.