Click here to Skip to main content
15,912,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am running javascript where i am scripting photoshop as well.
I am using following code :

var strtRulerUnits = preferences.rulerUnits;
var strtTypeUnits = preferences.typeUnits;
preferences.rulerUnits = Units.INCHES;
preferences.typeUnits = TypeUnits.POINTS;


But, i am getting error that preferences is undefined.
Why i am getting error new preferences?

Any help would be appreciated.


Thanks.
Posted
Updated 28-Jun-12 4:46am
v4
Comments
ZurdoDev 28-Jun-12 9:07am    
Where is preferences defined?
Tim Corey 28-Jun-12 9:16am    
Please use the "Improve question" link to add to your question. Please reserve the Solutions section for answers to your question.

Looking at this[^] page, it appears that you need to prefix preferences with app -

i.e
JavaScript
var strtRulerUnits = app.preferences.rulerUnits;
 
Share this answer
 
Comments
akkanshagupta 29-Jun-12 1:10am    
If I am using var strRulerUnits = app.preference.rulerUnits; then I am getting app undefined error.
enhzflep 29-Jun-12 1:19am    
Looks like you're doing something wrong then. The example code I linked to does this (uses the app object)
What version of PS are you using? CS2, CS3?
What does Adobe's forums have to say on the matter?
akkanshagupta 29-Jun-12 1:23am    
I am using Photoshop 7.0, and i am writing this code in external Javascript, and running that script through HTML file.
enhzflep 29-Jun-12 1:27am    
Ah-hah! In that case, you can't access these properties..
Photoshop has a JavaScript engine built-in. To get access to these properties, you need to be running the script WITH Photoshop.
The approach you're taking is akin to running a Javascript in Opera or Chrome that gets the size of the window from an instance of Internet Explorer - not going to happen.
akkanshagupta 29-Jun-12 1:29am    
Please give me any idea how to run script with photoshop. I am doing this first time, and don't have any idea about this.

Regards.
app.preferences.rulerUnits = Units.INCHES

etc. CM , MM , POINTS , PIXELS
 
Share this answer
 
Comments
OriginalGriff 2-May-22 1:29am    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 10 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more!
Answering old questions can be seen as rep-point hunting, which is a form of site abuse. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.

And when you do, posting non-solutions is a fine way to get you kicked as well ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900