-
AE scripting: process selected layers one by one
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!