Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions “Scripting” Add keyframe to all path shape

  • “Scripting” Add keyframe to all path shape

    Posted by Cyril Drouin on March 23, 2018 at 10:17 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 = myLayer.property("ADBE Root Vectors Group");
    for (var j = 1; j <= myContents.numProperties; j++){
    myContents.property(j).property("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

    Cyril Drouin replied 8 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • James Ronan

    March 26, 2018 at 11:13 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 = myLayer.property("Contents"); // Apply Function to Shapes contents propertySearch(myContents); } // 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 <= a.property(j).numProperties; k++) { // Check its a shape if (a.property(j).property(k) == a.property(j).property("ADBE Vector Shape")) { a.property(j).property(k).addKey(1); // add key } // End of Check // Repeat function. Recursively propertySearch(a.property(j).property(k)); } // End of K loop } // end of J for loop } // End of Function.

  • Cyril Drouin

    March 26, 2018 at 2:14 pm

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

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy