1

This is a followup question to the answer in script-to-automatically-snap-all-points-to-grid-in-adobe-illustrator. In the answer getIntegerPreference is used to find the grid setting. But the question is: How does one know what keys to query?

So how are we to know what keys to use like in the example below (keys in bold):

var ticks = prf.getIntegerPreference('Grid/Horizontal/Ticks');
var spacing = prf.getRealPreference('Grid/Horizontal/Spacing');

Is this documented somewhere or is there a method for pulling these and other related preference strings somehow? This post was the compelling reason that I signed up to StackExchange. There are so many poorly document things concerning AI scripting, thus this really peaked my interest when I saw it. Are there other hidden tricks and nuggets like this you can expound upon? ;-)

1
  • 1
    Good! Welcome to GD.Se. This is not a forum. But rather a Q & A site. Your not supposed to ask questions in answer fields. Be sure to accept answers that answer your question (you may want to wait a while before doing so if fr example a better answer comes along, in this case i doubt it). Then once your reputation hits 15 (in a few hours/days or so): be sure to vote up deserving questions and answers as its important to the inner functioning of the site ( maybe both upvote and accept). Leaving questions unaccepted is problematic for other stackexhange users in future.
    – joojaa
    Commented Dec 18, 2015 at 7:28

1 Answer 1

4

The functions are documented here. Keys are not documented, but hinted (its not possible to document them all as they are not all owned by Adobe). The preferences have to live somewhere and you can take a look at the preferences file to find out what preferences have been stored along with their names by opening the prefs file in a text editor.

You can find the the preference file is located in:

  • %appdata%\Adobe\Adobe Illustrator x.x Settings\en_GB\AIPrefs on windows computers. Where x.x is version, and language folder may differ.

  • Users//Library/Preferences/Illustrator x Settings/en_GB/AIPref on OSX. Where X is version number and language folder may differ.

A relevant excerpt from this file file looks like follows:

/maxUndoDepth 200
/undoDepth 5
/Grid {
    /Horizontal {
        /Spacing 34.0157470703
        /Ticks 2
    }
    /Vertical {
        /Spacing 34.0157470703
        /Ticks 2
    }
    /Posn 1
    /Style 0
}

This looks remarkably like PostScript or PDF dictionaries. So these are then the keys denoted with a slash (/) in front and sub dictionaries or arrays delimited by curly braces ({,}). To access a sub key you just add keys together with /.

So getting prefs for undo depth should look as follows:

app.preferences.getIntegerPreference('undoDepth');

While getting a subkey like spacing looks like:

app.preferences.getRealPreference('Grid/Horizontal/Spacing')

Note take care with asking keys, as a key is created every time you ask if it does not exist. The names are case sensitive.

4
  • Preference file location - Illustrator
    – Joonas
    Commented Dec 18, 2015 at 8:11
  • @joojaa, that was what I was looking for especially the Postscript/PDF slash & curly brace references. Thanks so much, wonderful answer. So in regards to the last thing you mentioned (asking keys) we can add custom settings to the Illustrator preference file? If so, is this advantageous or something that should be avoided (corruption?) ?
    – user55846
    Commented Jan 4, 2016 at 21:35
  • @LL15 You can add keys, just try avoid name clashes with others. Namespacing might bee a good idea. I add last used user setting in this script.
    – joojaa
    Commented Jan 4, 2016 at 23:15
  • @joojaa, ah thanks that's a perfect example for reference, thanks for all your insight on this topic, very much appreciated.
    – user55846
    Commented Jan 5, 2016 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.