From cgwiki
Jump to: navigation, search

Open multiple After Effects sessions

Hit the windows key and R at the same time, type

afterfx -m


Several tutorial sites mention a scripting interface, but I couldn't find it. Turns out its hidden, this page gave clues to where it is:

Go to creative cloud, prefs, turn on 'show older apps'. Restart creative cloud, you'll find Extendscript Toolkit CC. Amusingly you can't launch it from the creative cloud launcher, but it should be available from your Windows start menu.

That same web page says to set After Effects as the target, this is done from the first dropdown in the top left, where it says 'ExtendScript Toolkit CC', change that to 'Adobe After Effects 2022'.

There's also a way to link directly to VSCode, but last time I tried it refused to work. Will try again one day, using this link as a guide:

David Torno helpfully shared links to his pretty extensive free training series too, cool stuff:

Quick things:

  • F5 - run the script ( like ctrl-enter in a wrangle)
  • ctrl-shift-c - clear the console
  • $.writeln('foo'); - print something to the internal console in the extendscript editor
  • writeLn('foo'); - print something to the info panel within AE itself (make sure the panel is expanded first)

Find comp by name:

Good overview of how to get scripting going in 2022, especially with vscode instead of the extendscript editor:

Handy guide which is sorta kept more up to date than adobe's internal docs which for some reason are riddled with dead links:


Fiddly. How? Fiddly.

Get vertices from a shape layer path:

var myLayer = myComp.layer("Shape Layer 1");
points ="Contents").property("Path 2").property("ADBE Vector Shape").value.vertices;

Create a new shape, insert it into an existing shape path:

// make a shape
var myShape = new Shape();
myShape.vertices = [[0,0], [0,100], [100,100], [100,0]];
myShape.closed = true;

// find the existing shape in the comp, set the new shape
theshape ="Contents").property("Path 2").property("ADBE Vector Shape");
theshape.setValue(myShape );

Set Text Layers

Less fiddly than shapes. Which is nice. I also included how to get the comp, which is a modified version of a script linked further up, without all that pesky type checking and correct coding. :)

	for(var i=1;i<=app.project.numItems;i++)
		var curItem=app.project.item(i);
		if ( ) return curItem;
	return null;

var myComp = findItemByName ("MAIN_COMP");
myComp.layer("text1").property("Text").property("Source Text").setValue("my amazing new text");

paths on disk

Uses forward slashes, windows drive locations are gitbash style so /c/foo/bar:

var csvFile = File("/d/projects/myproj/data.csv");


Same pathing as above, can set includepath and include:

#includepath "/d/ae/libs/LST"
#include 'LST.js'

toComp and fromComp in scripting

You can't, its an expression thing only, arrgh. Luckily someone has written their own module to do space transformation, LST:


Handy command line interface to after effects that can control rendering, ffmpeg output, but most importantly allow for you to control AE, so its easy(ish) to swap layers, text, properties, you name it.

The docs above are pretty good, some extra tips cos I keep losing them in that big list:

  • layer searches are wildcarded across all comps by default, so if 'herovideo' is a layer in 6 comps, it will be replaced in all 6.
  • external jsx scripts can be called directly as part of the assets block in json:
        "src": "file:///y:/worktemp/show_it_to_me_update_shapes_v03.jsx",
        "type": "script"
  • text is replaced via a layer and property call, this is also wildcarded across all comps by default:
        "type": "data",
        "layerName": "video_title",
        "property": "Source Text",
        "value": "this is the new text"


Annoyingly while it seems its full javascript, its not. It's more like hscript/python expressions in that you can read from anywhere, but ony write to yourself (ie whatever the property/parameter it is that you're writing the expression in).

Debugging is also frustrating, as there's no console. You can print stuff kindasorta by forcing a fake expression with throw, eg

throw myvar;

You'll get an error, when you click in the expression field, the error (ie the thing you want) will be shown in a tooltip. This can't be copypasted though, so if you need to access these values, you need to create a text layer, and have the text expression fetch the thing you want. Frustrating.

Set shape via expression and csv

Similar but different to the jsx version:

let pts = []

data = footage("data.csv")
ptslength = thisComp.layer("data")("Data")("Number of Rows")
for (let i = 0; i < ptslength; i++) {
	pts[i] = [data.dataValue([0,i])*200-800,data.dataValue([2,i])*.1-2500];
createPath(pts, [], [], false);