After Effects CC 2017 (14.0) includes new scripting access to tools, composition markers, the Queue In AME command, and GPU acceleration options.
The documentation and sample code below explains how to use this new functionality. We plan to post this to our blog, later in November as a part of series of in-depth articles about the new features in After Effects CC 2017, but we heard enough interest today that we thought you might appreciate seeing this sooner.
(Please pardon any formatting errors that may have occurred when pasting the sample code into this forum. I did my best to clean it up.)
Scripting Access to Tools
You can now get and set the active tool in the Tools panel using the new app.project.toolType
attribute. This read/write attribute returns or accepts an enumerated ToolType value, of one of the following:
Value | Tool Name |
---|---|
ToolType.Tool_Arrow | Selection Tool |
ToolType.Tool_Rotate | Rotation Tool |
ToolType.Tool_CameraMaya | Unified Camera Tool |
ToolType.Tool_CameraOrbit | Orbit Camera Tool |
ToolType.Tool_CameraTrackXY | Track XY Camera Tool |
ToolType.Tool_CameraTrackZ | Track Z Camera Tool |
ToolType.Tool_Paintbrush | Brush Tool |
ToolType.Tool_CloneStamp | Clone Stamp Tool |
ToolType.Tool_Eraser | Eraser Tool |
ToolType.Tool_Hand | Hand Tool |
ToolType.Tool_Magnify | Zoom Tool |
GToolType.Tool_PanBehind | Pan Behind (Anchor Point) Tool |
ToolType.Tool_Rect | Rectangle Tool |
ToolType.Tool_RoundedRect | Rounded Rectangle Tool |
ToolType.Tool_Oval | Ellipse Tool |
ToolType.Tool_Polygon | Polygon Tool |
ToolType.Tool_Star | Star Tool |
ToolType.Tool_TextH | Horizontal Type Tool |
ToolType.Tool_TextV | Vertical Type Tool |
ToolType.Tool_Pen | Pen Tool |
ToolType.Tool_Feather | Mask Feather Tool |
ToolType.Tool_PenPlus | Add Vertex Tool |
ToolType.Tool_PenMinus | Delete Vertex Tool |
ToolType.Tool_PenConvert | Convert Vertex Tool |
ToolType.Tool_Pin | Puppet Pin Tool |
ToolType.Tool_PinStarch | Puppet Starch Tool |
ToolType.Tool_PinDepth | Puppet Overlap Tool |
ToolType.Tool_Quickselect | Roto Brush Tool |
ToolType.Tool_Hairbrush | Refine Edge Tool |
The following sample code checks the current tool, and if it is not the Unified Camera Tool, sets the current tool to that:
// Check the current tool, then set it to Unified Camera Tool (UCT). |
The following sample code uses the new app.project.toolType
attribute to create a 360° composition (environment layer and camera) from a selected footage item or composition selected in the Project panel. This script a good starting point for building VR compositions from equirectangular footage:
// Create a 360 VR comp from a footage item or comp selected in the Project panel. |
Scripting Access to Composition Markers
Composition markers can now be created and modified via the new comp.markerProperty
attribute. Composition marker scripting has the same functionality as layer markers.
The following sample code creates a project and composition, then creates two composition markers with different properties:
// comp.markerProperty allows you add markers to a comp. |
Scripting Access to Queue in AME
The Queue In AME command, introduced in After Effects CC 2015.3 (13.8), can now be triggered via scripting. This requires Adobe Media Encoder CC 2017 (11.0) or later.
The new method app.project.renderQueue.queueInAME(render_immediately_in_AME)
calls the Queue In AME command. This method requires passing a boolean value, telling AME whether to only queue the render items (false) or if AME should also start processing its queue (true).
Note that when AME receives the queued items, it applies the most recently used encoding preset. If render_immediately_in_AME
is set to true, you will not have an opportunity to change the encoding settings.
The new read-only boolean attribute app.project.renderQueue.canQueueInAME
indicates whether or not there are queued render items in the After Effects render queue. Only queued items can be added to the AME queue.
The following sample code checks to see if there are queued items in the render queue, and if so queues them in AME but does not immediately start rendering:
// Scripting support for Queue in AME. |
Scripting Access to Available GPU Acceleration Options
You can now use scripting to request which GPU acceleration types are available on the current computer. The new read-only attribute app.availableGPUAccelTypes
returns an array of gpuAccelType
enums.
Use this in conjunction with app.project.gpuAccelType
to set the value for Project Settings > Video Rendering and Effects > Use.
The following sample code checks the current computer's available GPU acceleration types, and sets it to Metal if available:
// app.availableGPUAccelTypes returns GPU acceleration types available on the current system. |