ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

"Scripting" Add keyframe to all path shape

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Cyril Drouin
"Scripting" Add keyframe to all path shape
on Mar 23, 2018 at 10:17:27 am

Hi Everyone,

I'm new in scripting but I try to write a simple script for adding a keyframe on every path of shape layer, i succeed with a part of that:
var myLayers = app.project.activeItem.selectedLayers;
var myLayer;
for (var i = 0; i < myLayers.length; i++){
myLayer = myLayers[i];
if (myLayer instanceof ShapeLayer){
var myContents ="ADBE Root Vectors Group");
for (var j = 1; j <= myContents.numProperties; j++){"ADBE Vectors Group").property("ADBE Vector Shape - Group").property("ADBE Vector Shape").addKey(1);

but i have difficult if there is a lot of "Vector Shape" on "Shape - Group" it doesn't work.

Do you have an idea how to do it ?

Thanks a lot

Return to posts index

James Ronan
Re: "Scripting" Add keyframe to all path shape
on Mar 26, 2018 at 11:13:53 am
Last Edited By James Ronan on Mar 26, 2018 at 11:18:59 am

You would need a recursive function to loop through each layers properties and groups etc.

It's a bit rough, but try this:

// Selected Layers
var myLayers = app.project.activeItem.selectedLayers;

//Loop through selected layers
for (var i = 0; i < myLayers.length; i++) {
myLayer = myLayers[i];

//Check if layer Shape Layer
if (myLayer instanceof ShapeLayer) {

//Find the contents
var myContents ="Contents");

// Apply Function to Shapes contents

} // End of If statement
} // End of for loop.

function propertySearch(a) {

//Loop through first set of properties
for (var j = 1; j <= a.numProperties; j++) {

// Loop through second set to find previous property group
for (var k = 1; k <=; k++) {

// Check its a shape
if ( =="ADBE Vector Shape")) {; // add key

} // End of Check

// Repeat function. Recursively

} // End of K loop

} // end of J for loop

} // End of Function.

Return to posts index

Cyril Drouin
Re: "Scripting" Add keyframe to all path shape
on Mar 26, 2018 at 2:14:07 pm

Thank a lot James i will see that and thanks for all your explanation in the code.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved