After Effects scripting referenceGlobal functions
16
isDuration
Optional. When true, the time is a duration (measured from frame 0). When false (the default), the time is measured from the project’s starting frame.
Returns
String in the project’s current time display format.
write() global function
write(text)Description
Writes output to the Info panel, with no line break added.
ParameterstextReturns
The string to display. Truncated if too long for the Info panel.
Nothing.
Example
write(\write(\
writeLn() global function
writeLn(text)Description
Writes output to the Info panel and adds a line break at the end.
ParameterstextReturns
The string to display.
Nothing.
Example
writeln(\writeln(\
16
After Effects scripting referenceApplication object
17
Application object
appDescription
Provides access to objects and application settings within the After Effects application. The single global object is always available by its name, app.
Attributes of the Application object provide access to specific objects within After Effects. Methods of the Application object can create a project, open an existing project, control Watch Folder mode, purge memory, and quit the After Effects application. When the After Effects application quits, it closes the open project, prompting the user to save or discard changes as necessary, and creates a project file as necessary.
AttributesAttribute
Reference
“Application project attribute” on page26 and “Project object” on page114
Description
The current After Effects project.
project
isoLanguageversionbuildNamebuildNumberisWatchFolderisRenderEnginesettings
“Application isoLanguage attribute” on The locale (language and region) in which the applica-page22tion is running.“Application version attribute” on page29
“Application buildName attribute” on page19
The version number of the After Effects application.The name of this build of the application.
“Application buildNumber attribute” on The number of this build of the application.page20
“Application isWatchFolder attribute” on When true, the local application is running in Watch page23Folder mode.“Application isRenderEngine attribute” on page23
When true, the local After Effects application is running as a render engine.
“Application settings attribute” on Application settings that can be set via scripting.page28 and “RQItemCollection object” on page169
“Application onError attribute” on page24
“Application exitCode attribute” on page22
A callback function that is called when an error occurs in the application.
A numeric status code used when executing a script externally (that is, from a command line or AppleScript). 0 if no error occurred. A positive number indicates an error that occurred while running the script.
When true, the application remains open after running a script from the command line on Windows.
When true, the project is saved if the application closes unexpectedly.
onErrorexitCode
exitAfterLaunchAndEval“Application exitAfterLaunchAndEval
attribute” on page22
saveProjectOnCrashmemoryInUseeffectsactiveViewer
“Application saveProjectOnCrash attri-bute” on page27
“Application memoryInUse attribute” on Memory in use by this application.page23
“Application effects attribute” on page20
“Application activeViewer attribute” on page19
The effects available in the application.
The currently focused or last-focused viewer panel.
17
After Effects scripting referenceApplication object
18
MethodsMethod
Reference
“Application newProject() method” on page24
“Application open() method” on page24“Application quit() method” on page27“Application watchFolder() method” on page29
“Application pauseWatchFolder() method” on page26
Description
Creates a new project in After Effects.Opens a project or an Open Project dialog box.Quits the application.
Starts Watch Folder mode; does not return until Watch Folder mode is turned off.Pauses a current watch-folder process.
newProject()open()quit()
watchFolder()pauseWatchFolder()endWatchFolder()purge()
beginUndoGroup()endUndoGroup()beginSuppressDialogs()endSuppressDialogs()setMemoryUsageLimits()setSavePreferencesOnQuit()activate()scheduleTask()cancelTask()parseSwatchFile()
“Application endWatchFolder() method” on Ends a current watch-folder process.page21
“Application purge() method” on page26“Application beginUndoGroup() method” on page19
Purges a targeted type of cached information (replicates Purge options in the Edit menu).Groups the actions that follow it into a single undoable step.
“Application endUndoGroup() method” on Ends an undo group; needed only when a page21script contains more than one undo group.“Application beginSuppressDialogs() method” on page19
“Application endSuppressDialogs() method” on page21
“Application setMemoryUsageLimits() method” on page28
“Application setSavePreferencesOnQuit() method” on page28
Begins suppression of dialogs in the user inter-face.
Ends suppression of dialogs in the user inter-face.
Sets memory usage limits as in the Memory & Cache preferences area.
Sets whether preferences are saved when the application is quit.
“Application activate() method” on page18Brings the After Effects main window to the
front of the screen.“Application scheduleTask() method” on page27
“Application cancelTask() method” on page20
Schedules a JavaScript script for delayed exe-cution.
Cancels a scheduled task.
“Application parseSwatchFile() method” on Loads a color swatch from an Adobe Swatch page25Exchange (ASE) file.
Application activate() method
app.activate()Description
Opens the application main window if it is minimized or iconified, and brings it to the front of the desktop.
Parameters
None.
18
After Effects scripting referenceApplication object
19
Returns
Nothing.
Application activeViewer attribute
app.activeViewerDescription
The Viewer object for the currently focused or active-focused viewer (Composition, Layer, or Footage) panel. Returns null if no viewers are open.
Type
Viewer object; read-only.
Application beginSuppressDialogs() method
app.beginSuppressDialogs()Description
Begins suppression of script error dialog boxes in the user interface. Use endSuppressDialogs() to resume the display of error dialogs. See “Application endSuppressDialogs() method” on page21.
Parameters
None.
Returns
Nothing.
Application beginUndoGroup() method
app.beginUndoGroup(undoString)Description
Marks the beginning of an undo group, which allows a script to logically group all of its actions as a single undoable action (for use with the Edit > Undo/Redo menu items). Use the endUndoGroup() method to mark the end of the group. (See “Application endUndoGroup() method” on page21.)
beginUndoGroup() and endUndoGroup() pairs can be nested. Groups within groups become part of the
larger group, and will undo correctly. In this case, the names of inner groups are ignored.
ParametersundoStringReturns
The text that will appear for the Undo command in the Edit menu (that is, “Undo
Nothing.
Application buildName attribute
app.buildName
19
After Effects scripting referenceApplication object
20
Description
The name of the build of After Effects being run, used internally by Adobe for testing and troubleshooting.
Type
String; read-only.
Application buildNumber attribute
app.buildNumberDescription
The number of the build of After Effects being run, used internally by Adobe for testing and troubleshooting.
Type
Integer; read-only.
Application cancelTask() method
app.cancelTask(taskID)Description
Removes the specified task from the queue of tasks scheduled for delayed execution.
ParameterstaskIDReturns
An integer that identifies the task, as returned by app.scheduleTask().
Nothing.
Application effects attribute
app.effectsDescription
The effects available in the application.
Type
Array, with each element containing the following properties; read-only:
displayNamecategorymatchName
String representing the localized display name of the effect as seen in the Effect menu.
String representing the localized category label as seen in the Effect menu. This can be \effects that aren’t normally shown to the user.
String representing the internal unique name for the effect. This name does not change between ver-sions of After Effects. Use this value to apply the effect.
Example
var effectName = app.effects[12].displayName;
20