• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to get or set units?!

Contributor ,
May 26, 2016 May 26, 2016

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

TOPICS
Actions and scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 26, 2016 May 26, 2016

app.preferences.rulerUnits = Units.PIXELS;//sets the units to pixels

var whatUnits = app.preferences.rulerUnits;//gets whatever the current units are.

Votes

Translate

Translate
Adobe
Advisor ,
May 26, 2016 May 26, 2016

Copy link to clipboard

Copied

app.preferences.rulerUnits

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 26, 2016 May 26, 2016

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 26, 2016 May 26, 2016

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 27, 2016 May 27, 2016

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 27, 2016 May 27, 2016

Copy link to clipboard

Copied

Dominique, Chuck, Xbytor2 Many thanks... after this it was a piece of cake!

Ben

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 27, 2016 May 27, 2016

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!!! 😄

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 27, 2016 May 27, 2016

Copy link to clipboard

Copied

Info like what?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 27, 2016 May 27, 2016

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! ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 27, 2016 May 27, 2016

Copy link to clipboard

Copied

LATEST

The "Photoshop Scriptref.pdf" has sample scripts. You can also look at scripts that come with PS for how things are done.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines