After Effects scripting referenceApplication object
21
Application endSuppressDialogs() method
app.endSuppressDialogs(alert)Description
Ends the suppression of script error dialog boxes in the user interface. Error dialogs are displayed by default; call this method only if beginSuppressDialogs() has previously been called. See “Application beginSuppress-Dialogs() method” on page19.
Parametersalert
Boolean; when true, errors that have occurred following the call to beginSuppressDialogs() are displayed in a dialog box.
Returns
Nothing.
Application endUndoGroup() method
app.endUndoGroup()Description
Marks the end of an undo group begun with the app.beginUndoGroup() method. You can use this method to place an end to an undo group in the middle of a script, should you wish to use more than one undo group for a single script.
If you are using only a single undo group for a given script, you do not need to use this method; in its absence at the end of a script, the system will close the undo group automatically.
Calling this method without having set a beginUndoGroup() method yields an error.
Parameters
None.
Returns
Nothing.
Application endWatchFolder() method
app.endWatchFolder()Description
Ends Watch Folder mode.
Parameters
None.
Returns
Nothing.
21
After Effects scripting referenceApplication object
22
See also
“Application watchFolder() method” on page29“Application parseSwatchFile() method” on page25“Application isWatchFolder attribute” on page23
Application exitAfterLaunchAndEval attribute
app.exitAfterLaunchAndEvalDescription
This attribute is used only when executing a script from a command line on Windows. When the application is launched from the command line, the –r or –s command line flag causes the application to run a script (from a file or from a string, respectively).
If this attribute is set to true, After Effects will exit after the script is run; if it is false, the application will remain open.
This attribute only has an effect when After Effects is run from the Windows command line. It has no effect in Mac OS.
Type
Boolean; read/write.
Application exitCode attribute
app.exitCodeDescription
A numeric status code used when executing a script externally (that is, from a command line or AppleScript).
?In Windows, the value is returned on the command line when After Effects was launched on the command
line (using the afterfx or afterfx –m command), and a script was specified with the –r or –s option.
?in Mac OS, the value is returned as the AppleScript DoScript result for each script.
In both Mac OS and Windows, the value is set to 0 (EXIT_SUCCESS) at the beginning of each script evalu-ation. In the event of an error while the script is running, the script can set this to a positive integer that indicates what error occurred.
Type
Integer; read/write.
Example
app.exitCode = 2; //on quit, if value is 2, an error has occurred
Application isoLanguage attribute
app.isoLanguageDescription
A string indicating the locale (language and regional designations) After Effects is running.NOTE: $.locale returns the operating system language, not the language of the After Effects application.
22
After Effects scripting referenceApplication object
23
Type
String; read-only. Some common values include:
?en_US for English (United States)?de_DE for German (Germany)?es_ES for Spanish (Spain)?fr_FR for French (France)?it_IT for Italian (Italy)?ja_JP for Japanese (Japan)?ko_KR for Korean (Korea)
Example
var lang = app.isoLanguage;if (lang == \
alert(\else if (lang == \
alert(\else
alert(\
Application isRenderEngine attribute
app.isRenderEngineDescription
True if After Effects is running as a render engine.
Type
Boolean; read-only.
Application isWatchFolder attribute
app.isWatchFolderDescription
True if the Watch Folder dialog box is currently displayed and the application is currently watching a folder for rendering.
Type
Boolean; read-only.
Application memoryInUse attribute
app.memoryInUseDescription
The number of bytes of memory currently used by this application.
23
After Effects scripting referenceApplication object
24
Type
Number; read-only.
Application newProject() method
app.newProject()Description
Creates a new project in After Effects, replicating the File > New > New Project menu command.
If the current project has been edited, the user is prompted to save it. If the user cancels out of the Save dialog box, the new project is not created and the method returns null. Use app.project.close(CloseOp-tions.DO_NOT_SAVE_CHANGES) to close the current project before opening a new one. See “Project close() method” on page116.
Parameters
None.
Returns
A new Project object, or null if no new project is created.
Example
app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);app.newProject();
Application onError attribute
app.onErrorDescription
The name of a callback function that is called when an error occurs. By creating a function and assigning it to this attribute, you can respond to errors systematically; for example, you can close and restart the application, noting the error in a log file if it occurred during rendering. See “RenderQueue render() method” on page161.The callback function is passed the error string and a severity string. It should not return any value.
Type
A function name string, or null if no function is assigned; read/write.
Example
function err(errString) {alert(errString); }
app.onError = err;
Application open() method
app.open()app.open(file)
24
After Effects scripting referenceApplication object
25
Description
Opens a project.
Parametersfile
Optional. An ExtendScript File object for the project file to open. If not supplied, the method prompts the user to select a project file.
Returns
A new Project object for the specified project, or null if the user cancels the Open dialog box.
Example
var my_file = new File(\if (my_file.exists){
new_project = app.open(my_file);if (new_project){
alert(new_project.file.name);}}
Application parseSwatchFile() method
app.parseSwatchFile(file)Description
Loads color swatch data from an Adobe Swatch Exchange (ASE) file.
ParametersfileReturns
The file specification, an ExtendScript File object.
The swatch data, in this format:
data.majorVersiondata.minorVersiondata.valuesSwatchValue.typeSwatchValue.rSwatchValue.gSwatchValue.bSwatchValue.cSwatchValue.mSwatchValue.ySwatchValue.k
When type = \, the color values in the range [0.0..1.0]. 0, 0, 0, 0 is White.
An array of SwatchValue.
One of \
When type = \, the color values in the range [0.0..1.0]. 0, 0, 0 is Black.
The ASE version number.
25