ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Script not working AE 2019

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sam Pillar
Script not working AE 2019
on Jul 24, 2019 at 9:49:39 am

Hi! Currently working on a project with a load of layer styles. I have a script that toggles layer styles on and off which works in previous versions of AE.

When I run the script, i get an error message saying "Unable to execute script at line 10. undefined is not an object"

Can anyone help me with this? Pretty newbie with scripting.

Here is the code:
var activeComp = app.project.activeItem;
if (activeComp == null) {
alert("Select a composition.");
} else {
toggleLayerStyles(activeComp);
}
function toggleLayerStyles(curComp) {
for (var i = 1; i <= curComp.layers.length; i++) {
curL = curComp.layer(i);
if (curL.layerStyle.canSetEnabled == true) {
if (curL.layerStyle.enabled == true) {
curL.layerStyle.enabled = false;
} else {
curL.layerStyle.enabled = true;
}
}
if (curL.source instanceof CompItem) {
toggleLayerStyles(curL.source);
}
}
}


Return to posts index

Dan Ebberts
Re: Script not working AE 2019
on Jul 24, 2019 at 7:25:26 pm

My guess is that your comp has a camera in it (or some other non-AV layer). Try changing line 10 to this:

if (curL instanceof (AVLayer ) && curL.layerStyle.canSetEnabled == true) {


Dan



Return to posts index

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