Skip to main content
Known Participant
September 24, 2019
Answered

Photoshop script to set units to percentage temporarily

  • September 24, 2019
  • 2 replies
  • 2257 views

Hello, 

 

I'm relatively new to scripting and have relied heavily on this forum for learning. However, since the redesign all my bookmarks are broken and I have found the search function to be really, really difficult to find anything. 

 

I am trying to find a simple way to change the ruler units to percentage temporarily while I resize an object, then restore the user prefs once I am done resizing the object. 

 

Any help is greatly appreciated. Thanks in advance!


~ Joe D

This topic has been closed for replies.
Correct answer Chuck Uebele

Ues this to save the current settings then to change to percent, then to reset:

 

var oldPref = app.preferences.rulerUnits;//save current units
app.preferences.rulerUnits = Units.PERCENT;
//code here
//reset units
app.preferences.rulerUnits = oldPref;

2 replies

Chuck Uebele
Community Expert
Chuck UebeleCommunity ExpertCorrect answer
Community Expert
September 24, 2019

Ues this to save the current settings then to change to percent, then to reset:

 

var oldPref = app.preferences.rulerUnits;//save current units
app.preferences.rulerUnits = Units.PERCENT;
//code here
//reset units
app.preferences.rulerUnits = oldPref;
thejoed1Author
Known Participant
October 1, 2019
Thank you Chuck!
Norman Sanders
Legend
September 24, 2019

If you are referring to the Ruler along the top and left side of the image, a right chick on the Ruler will give you that option, among others.

thejoed1Author
Known Participant
October 1, 2019
Hi Norman, thanks for responding. I was wondering how to do it as a script. All good. Thanks again.