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

[Q] Is the Grid and Gridline Every setting in Illustrator scriptable?

Explorer ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

I can't find anything on how to script the Illustrator's grid in JavaScript. In particular I am looking for the GridLine Every setting, as in the Preferences dialogue box:

 

tomd75724979_0-1695502194191.png

Any help greatly appreciated,

 

Tom

TOPICS
How-to , Scripting

Views

298

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

Explorer , Sep 23, 2023 Sep 23, 2023

Hi Kurt,

 

I'm so happy - and I hope you are too - to tell you that you're wrong 🙂

 

I found this and it works. cm2pts is just my conversion constant for converting centimeters to points.

 

app.preferences.setRealPreference('Grid/Horizontal/Spacing', 0.9*cm2pts)
$.writeln("Spacing: " + app.preferences.getRealPreference('Grid/Horizontal/Spacing'));

app.preferences.setRealPreference('Grid/Vertical/Spacing', 0.9*cm2pts)
$.writeln("Spacing: " + app.preferences.getRealPreference('Grid/Horizontal/Spacing'));

a
...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

As far as I know this setting is currently not accessible to JavaScript.

 

Hopefully I'm wrong here.

 

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
Explorer ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

Hi Kurt,

 

I'm so happy - and I hope you are too - to tell you that you're wrong 🙂

 

I found this and it works. cm2pts is just my conversion constant for converting centimeters to points.

 

app.preferences.setRealPreference('Grid/Horizontal/Spacing', 0.9*cm2pts)
$.writeln("Spacing: " + app.preferences.getRealPreference('Grid/Horizontal/Spacing'));

app.preferences.setRealPreference('Grid/Vertical/Spacing', 0.9*cm2pts)
$.writeln("Spacing: " + app.preferences.getRealPreference('Grid/Horizontal/Spacing'));

app.preferences.setIntegerPreference('Grid/Horizontal/Ticks', 1);
app.preferences.setIntegerPreference('Grid/Vertical/Ticks', 1);

$.writeln("Hor ticks: " + app.preferences.getIntegerPreference('Grid/Horizontal/Ticks'));
$.writeln("Vert ticks: " + app.preferences.getIntegerPreference('Grid/Vertical/Ticks'));

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 ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

I haven't tried your approach yet, but if it works I'm certainly happy that I was wrong.

 

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 ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

did it update the active document's grid on your end? 

 

updating the pref file grid did update the settings at an application level. New files will inherit the new grid settings, but documents already open will not change the grid size on my testing.

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 ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

LATEST

I meant to reply to the OP Kurt, not to your post sorry about that

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