Skip to main content
July 13, 2020
Question

Can someone please give me a script that changes the ruler metric?

  • July 13, 2020
  • 3 replies
  • 1312 views

I just want to run a script that changes whatever the current ruler is to inches, thank you!

This topic has been closed for replies.

3 replies

Charu Rajput
Community Expert
Community Expert
July 14, 2020

Hello,

Try following snippet

var units = 3; //(0 to 6)
app.preferences.setIntegerPreference("rulerType", units);

/*Unit list
0 : point
1 : pica
2 : inch
3 : mm
4 : cm
5 : H/Q
6 : px */

 

This will change the ruler units in Units for "General" in Preferences -> Units. So, you can combine this with solution of femkeblanco 

 

Best regards
July 14, 2020

Thanks, I did see this from an earlier post but I just can't seem to get it to work. 

femkeblanco
Legend
July 14, 2020

You can set the units when you create a new document:

 

var preset1 = new DocumentPreset;
preset1.units = RulerUnits.Inches;
var doc1 = app.documents.addDocument("Basic CMYK", preset1);

 

but I don't think you can change them after that.

 

app.executeMenuCommand("unitundoPref") brings up the units dialog box, but you will have to select your units manually.  
m1b
Community Expert
Community Expert
July 13, 2020

I actually couldn't find a way to do this with a script, but hopefully someone else will know. But just checking that you know you can right-click on the ruler to change units?

July 13, 2020

thanks, yeah I know I can righ-click but I'd like a script so that I can work it into a series of tasks in an action.