AfterEffects

From cgwiki
Jump to: navigation, search

Scripting

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:

https://www.codeandmotion.com/blog/after-effects-absolute-beginners

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'.

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

Find comp by name: https://gist.github.com/dokluch/1ca33a65dc67d4a3047f

Shapes

Fiddly. How? Fiddly.

Get vertices from a shape layer path:

var myLayer = myComp.layer("Shape Layer 1");
points = myLayer.property("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 = myLayer.property("Contents").property("Path 2").property("ADBE Vector Shape");
theshape.setValue(myShape );

Expressions

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.