preferences
Preferences object
Section titled “Preferences object”app.preferences
Description
Section titled “Description”The Preferences object provides an easy way to manage internal AE preferences, such as you’d find in AE’s Preferences menu. These are saved in the After Effects preference files, and are persistent between application sessions.
Preferences are identified by section and key within the file, and each key name is associated with a value.
In the preferences file, section names are enclosed in brackets and quotation marks, and key names are listing in quotation marks below the sectionname. All values are strings.
You can create new preferences with this object, as well as accessing existing preferences.
As of Version 12/CC, preferences and settings methods now take a third argument to specify the target preferences file if Section/Key is not in “Adobe After Effects $versionNumber.x Prefs.txt”.
If the third argument is not passed, default value (PREFType.PREF_Type_MACHINE_SPECIFIC
) is used and After Effects tries to save/get from the “Adobe After Effects $versionNumber.x Prefs.txt” preferences file.
PREFType Enum
Section titled “PREFType Enum”The third argument is enum PREFType
value, one of:
PREF_Type_MACHINE_SPECIFIC
: Adobe After Effects $versionNumber.x Prefs.txtPREF_Type_MACHINE_INDEPENDENT
: Adobe After Effects $versionNumber.x Prefs-indep-general.txtPREF_Type_MACHINE_INDEPENDENT_RENDER
: Adobe After Effects $versionNumber.x Prefs-indep-render.txtPREF_Type_MACHINE_INDEPENDENT_OUTPUT
: Adobe After Effects $versionNumber.x Prefs-indep-output.txtPREF_Type_MACHINE_INDEPENDENT_COMPOSITION
: Adobe After Effects $versionNumber.x Prefs-indep-composition.txtPREF_Type_MACHINE_SPECIFIC_TEXT
: Adobe After Effects $versionNumber.x Prefs-text.txtPREF_Type_MACHINE_SPECIFIC_PAINT
: Adobe After Effects $versionNumber.x Prefs-paint.txt
Methods
Section titled “Methods”Preferences.deletePref()
Section titled “Preferences.deletePref()”app.preferences.deletePref(sectionName, keyName[, prefType])
Description
Section titled “Description”Deletes a preference from the preference file.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
sectionName | String | The name of a preferences section. |
keyName | String | The key name of the preference. |
prefType | PREFType enum | Optional. Which preference file to use. |
Returns
Section titled “Returns”Nothing.
Example
Section titled “Example”If you have saved a setting named with the key name “trimPrecomps” in a section called “Precomp Cropper”, you can delete the setting by:
app.preferences.deletePref("Settings_Precomp Cropper", "trimPrecomps");
Preferences.getPrefAsBool()
Section titled “Preferences.getPrefAsBool()”app.preferences.getPrefAsBool(sectionName, keyName[, prefType])
Description
Section titled “Description”Retrieves a preference value from the preferences file, and parses it as a boolean.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
sectionName | String | The name of a preferences section. |
keyName | String | The key name of the preference. |
prefType | PREFType enum | Optional. Which preference file to use. |
Returns
Section titled “Returns”Boolean.
Example
Section titled “Example”To retrieve the value of the Flow Chart “Expand Flowchart Comps by Default” preference:
var expandByDefault = app.preferences.getPrefAsBool("Flowchart Settings", "Expand Flowchart Comps by Default");alert("The setting is: " + expandByDefault);
To retrieve the value of the main preference “Javascript Debugger Enabled”:
var debuggerEnabled = app.preferences.getPrefAsBool("Main Pref Section v2", "Pref_JAVASCRIPT_DEBUGGER", PREFType.PREF_Type_MACHINE_INDEPENDENT);alert("The setting is: " + debuggerEnabled);
Preferences.getPrefAsFloat()
Section titled “Preferences.getPrefAsFloat()”app.preferences.getPrefAsFloat(sectionName, keyName[, prefType])
Description
Section titled “Description”Retrieves a preference value from the preferences file, and parses it as a float.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
sectionName | String | The name of a preferences section. |
keyName | String | The key name of the preference. |
prefType | PREFType enum | Optional. Which preference file to use. |
Returns
Section titled “Returns”Float.
Preferences.getPrefAsLong()
Section titled “Preferences.getPrefAsLong()”app.preferences.getPrefAsLong(sectionName, keyName[, prefType])
Description
Section titled “Description”Retrieves a preference value from the preferences file, and parses it as a long (number).
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
sectionName | String | The name of a preferences section. |
keyName | String | The key name of the preference. |
prefType | PREFType enum | Optional. Which preference file to use. |
Returns
Section titled “Returns”Long.
Preferences.getPrefAsString()
Section titled “Preferences.getPrefAsString()”app.preferences.getPrefAsString(sectionName, keyName[, prefType])
Description
Section titled “Description”Retrieves a preference value from the preferences file, and parses it as a string.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
sectionName | String | The name of a preferences section. |
keyName | String | The key name of the preference. |
prefType | PREFType enum | Optional. Which preference file to use. |
Returns
Section titled “Returns”String.
Preferences.havePref()
Section titled “Preferences.havePref()”app.preferences.havePref(sectionName, keyName[, prefType])
Description
Section titled “Description”Returns true
if the specified preference item exists and has a value.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
sectionName | String | The name of a preferences section. |
keyName | String | The key name of the preference. |
prefType | PREFType enum | Optional. Which preference file to use. |
Returns
Section titled “Returns”Boolean.
Preferences.reload()
Section titled “Preferences.reload()”app.preferences.reload()
Description
Section titled “Description”Reloads the preferences file manually. Otherwise, changes to preferences will only be accessible by scripting after an application restart.
Parameters
Section titled “Parameters”None.
Returns
Section titled “Returns”Nothing.
Preferences.savePrefAsBool()
Section titled “Preferences.savePrefAsBool()”app.preferences.savePrefAsBool(sectionName, keyName, value[, prefType])
Description
Section titled “Description”Saves a preference item as a boolean.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
sectionName | String | The name of a preferences section. |
keyName | String | The key name of the preference. |
value | Boolean | The new value. |
prefType | PREFType enum | Optional. Which preference file to use. |
Returns
Section titled “Returns”Nothing.
Preferences.savePrefAsFloat()
Section titled “Preferences.savePrefAsFloat()”app.preferences.savePrefAsFloat(sectionName, keyName, value[, prefType])
Description
Section titled “Description”Saves a preference item as a float.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
sectionName | String | The name of a preferences section. |
keyName | String | The key name of the preference. |
value | Floating-point value | The new value. |
prefType | PREFType enum | Optional. Which preference file to use. |
Returns
Section titled “Returns”Nothing.
Preferences.savePrefAsLong()
Section titled “Preferences.savePrefAsLong()”app.preferences.savePrefAsLong(sectionName, keyName, value[, prefType])
Description
Section titled “Description”Saves a preference item as a long.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
sectionName | String | The name of a preferences section. |
keyName | String | The key name of the preference. |
value | Long value | The new value. |
prefType | PREFType enum | Optional. Which preference file to use. |
Returns
Section titled “Returns”Nothing.
Preferences.savePrefAsString()
Section titled “Preferences.savePrefAsString()”app.preferences.savePrefAsString(sectionName, keyName, value[, prefType])
Description
Section titled “Description”Saves a preference item as a string.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
sectionName | String | The name of a preferences section. |
keyName | String | The key name of the preference. |
value | String | The new value. |
prefType | PREFType enum | Optional. Which preference file to use. |
Returns
Section titled “Returns”Nothing.
Preferences.saveToDisk()
Section titled “Preferences.saveToDisk()”app.preferences.saveToDisk()
Description
Section titled “Description”Saves the preferences to disk manually. Otherwise, changes to preferences will only be accessible by scripting after an application restart.
Parameters
Section titled “Parameters”None.
Returns
Section titled “Returns”Nothing.