Skip to content

preferences

app.preferences

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.

The third argument is enum PREFType value, one of:

  • PREF_Type_MACHINE_SPECIFIC: Adobe After Effects $versionNumber.x Prefs.txt
  • PREF_Type_MACHINE_INDEPENDENT: Adobe After Effects $versionNumber.x Prefs-indep-general.txt
  • PREF_Type_MACHINE_INDEPENDENT_RENDER: Adobe After Effects $versionNumber.x Prefs-indep-render.txt
  • PREF_Type_MACHINE_INDEPENDENT_OUTPUT: Adobe After Effects $versionNumber.x Prefs-indep-output.txt
  • PREF_Type_MACHINE_INDEPENDENT_COMPOSITION: Adobe After Effects $versionNumber.x Prefs-indep-composition.txt
  • PREF_Type_MACHINE_SPECIFIC_TEXT: Adobe After Effects $versionNumber.x Prefs-text.txt
  • PREF_Type_MACHINE_SPECIFIC_PAINT: Adobe After Effects $versionNumber.x Prefs-paint.txt

app.preferences.deletePref(sectionName, keyName[, prefType])

Deletes a preference from the preference file.

ParameterTypeDescription
sectionNameStringThe name of a preferences section.
keyNameStringThe key name of the preference.
prefTypePREFType enumOptional. Which preference file to use.

Nothing.

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

app.preferences.getPrefAsBool(sectionName, keyName[, prefType])

Retrieves a preference value from the preferences file, and parses it as a boolean.

ParameterTypeDescription
sectionNameStringThe name of a preferences section.
keyNameStringThe key name of the preference.
prefTypePREFType enumOptional. Which preference file to use.

Boolean.

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

app.preferences.getPrefAsFloat(sectionName, keyName[, prefType])

Retrieves a preference value from the preferences file, and parses it as a float.

ParameterTypeDescription
sectionNameStringThe name of a preferences section.
keyNameStringThe key name of the preference.
prefTypePREFType enumOptional. Which preference file to use.

Float.


app.preferences.getPrefAsLong(sectionName, keyName[, prefType])

Retrieves a preference value from the preferences file, and parses it as a long (number).

ParameterTypeDescription
sectionNameStringThe name of a preferences section.
keyNameStringThe key name of the preference.
prefTypePREFType enumOptional. Which preference file to use.

Long.


app.preferences.getPrefAsString(sectionName, keyName[, prefType])

Retrieves a preference value from the preferences file, and parses it as a string.

ParameterTypeDescription
sectionNameStringThe name of a preferences section.
keyNameStringThe key name of the preference.
prefTypePREFType enumOptional. Which preference file to use.

String.


app.preferences.havePref(sectionName, keyName[, prefType])

Returns true if the specified preference item exists and has a value.

ParameterTypeDescription
sectionNameStringThe name of a preferences section.
keyNameStringThe key name of the preference.
prefTypePREFType enumOptional. Which preference file to use.

Boolean.


app.preferences.reload()

Reloads the preferences file manually. Otherwise, changes to preferences will only be accessible by scripting after an application restart.

None.

Nothing.


app.preferences.savePrefAsBool(sectionName, keyName, value[, prefType])

Saves a preference item as a boolean.

ParameterTypeDescription
sectionNameStringThe name of a preferences section.
keyNameStringThe key name of the preference.
valueBooleanThe new value.
prefTypePREFType enumOptional. Which preference file to use.

Nothing.


app.preferences.savePrefAsFloat(sectionName, keyName, value[, prefType])

Saves a preference item as a float.

ParameterTypeDescription
sectionNameStringThe name of a preferences section.
keyNameStringThe key name of the preference.
valueFloating-point valueThe new value.
prefTypePREFType enumOptional. Which preference file to use.

Nothing.


app.preferences.savePrefAsLong(sectionName, keyName, value[, prefType])

Saves a preference item as a long.

ParameterTypeDescription
sectionNameStringThe name of a preferences section.
keyNameStringThe key name of the preference.
valueLong valueThe new value.
prefTypePREFType enumOptional. Which preference file to use.

Nothing.


app.preferences.savePrefAsString(sectionName, keyName, value[, prefType])

Saves a preference item as a string.

ParameterTypeDescription
sectionNameStringThe name of a preferences section.
keyNameStringThe key name of the preference.
valueStringThe new value.
prefTypePREFType enumOptional. Which preference file to use.

Nothing.


app.preferences.saveToDisk()

Saves the preferences to disk manually. Otherwise, changes to preferences will only be accessible by scripting after an application restart.

None.

Nothing.