Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions AE scripting: process selected layers one by one

  • AE scripting: process selected layers one by one

    Posted by Peter Zeet on October 24, 2019 at 4:29 pm

    Hi!
    thanks to the bodymovin github page, I could figure out how to delete all the text animators from a layer via scripting.

    But it seems one layer must be processed at a time in order to select the text animators and delete them.
    An easy thing such having the layers from the array and process them one by one, is still a mystery for me to achieve via scripting.

    Any help figuring out what extra loop should I add? so having a bunch of selected layers, make it all process on every layer in the loop one at a time, to make it work? (another option is just creating a ui button and click on every layer manually )

    this is the code I came up with:
    var myLayers = app.project.activeItem.selectedLayers;
    var myLayer;
    for (var i = 0; i < myLayers.length; i++){
    myLayer = myLayers[i];

    function removeLayerAnimators(myLayer){
    var textProperty = myLayer.property("Text");
    var i, len = textProperty.numProperties;
    for (i = 0; i < len; i += 1) {
    switch (textProperty(i + 1).matchName) {
    case "ADBE Text Animators":
    removeAnimators(textProperty(i + 1));
    break;
    }
    }
    }

    function removeAnimators(myLayer) {
    var i, len = myLayer.numProperties;
    for (i = 0; i < len; i += 1) {
    if (myLayer.property(i + 1).matchName === "ADBE Text Animator") {
    myLayer.property(i + 1).remove();
    i -= 1;
    len -= 1;
    }
    }
    }

    }

    removeLayerAnimators(myLayer);
    removeAnimators(myLayer)

    thanks!

    Peter Zeet replied 6 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 24, 2019 at 4:52 pm

    With just a quick look, I’d suggest you try moving the functions outside of your loop and move the function calls (the last two lines of your script) inside the loop.

    Dan

  • Peter Zeet

    October 24, 2019 at 5:04 pm

    it worked!!
    many thanks!

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