Mobile app version of vmapp.org
Login or Join
Cugini998

: Illustrator Scripting - Preference Strings - How to obtain? This is a followup question to the answer in script-to-automatically-snap-all-points-to-grid-in-adobe-illustrator. In the answer getIntegerPreference

@Cugini998

Posted in: #IllustratorScripting

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? ;-)

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Cugini998

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cugini998

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%AdobeAdobe Illustrator x.x Settingsen_GBAIPrefs 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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme