Skip to main content
Participant
August 12, 2014
Answered

Set unit preferences (Javascript)

  • August 12, 2014
  • 2 replies
  • 14284 views

I can't find a way to set the unit preferences for Illustrator CS6/CC using JavaScript.

I found that this works (setting units for stroke):

var units = 2; // 0-inches, 1-milllimeters, 2-points

app.preferences.setIntegerPreference("strokeUnits", units)

But I want to set the ruler units ("General" in the interface), and this does not work:

app.preferences.setIntegerPreference("rulerUnits", units)

Any help?

Peter

This topic has been closed for replies.
Correct answer Ten A

Hi,

We can set ruler unit using "rulerType" key not "rulerUnit".

Check below script:

var units = 0; //(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

*/

Ten

2 replies

PBossensAuthor
Participant
September 1, 2014

Ten,

Yes, this works, finally! Thank you very much with this simple but poorly documented feature.

I noticed that the unit mapping is:  0: inches, 1: mm, 2: points, 3: pica, 4: cm, 5: custom, 6: pixels

Regards,

Peter

Ten A
Community Expert
Community Expert
September 1, 2014

Oops! Apologies for my mistake.

I'll update my documentation, Thanks.

Ten

Participating Frequently
October 22, 2014

Where can I find the documentation for all preference set via the setIntegerPreference and similar methods on app.preferences ?

Ten A
Community Expert
Ten ACommunity ExpertCorrect answer
Community Expert
August 26, 2014

Hi,

We can set ruler unit using "rulerType" key not "rulerUnit".

Check below script:

var units = 0; //(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

*/

Ten