ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

AE scripting: process selected layers one by one

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Peter Zeet
AE scripting: process selected layers one by one
on Oct 24, 2019 at 4:29:49 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!


Return to posts index

Dan Ebberts
Re: AE scripting: process selected layers one by one
on Oct 24, 2019 at 4:52:07 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



Return to posts index

Peter Zeet
Re: AE scripting: process selected layers one by one
on Oct 24, 2019 at 5:04:00 pm

it worked!!
many thanks!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]