ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

After Effects script to hide and show layer styles.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Toms Burāns
After Effects script to hide and show layer styles.
on Jul 5, 2017 at 4:03:10 pm

Hi! I have a rather complex character rig with many nested compositions and a lot of expressions to drive it. Almost all layers that make up the character have some layer styles applied. (inner shadow, inner glow etc). The thing is, the rig is starting to get very slow and laggy. When I disable the layer styles it moves a lot faster but turning them on and off one by one is not ideal. Could this be done with a script? Ideally, it would disable/enable all layer styles in the current comp as well as in all nested comps inside it. I don't have any experience with scripts, only expressions. Any help is greatly appreciated!


Return to posts index

Toms Burāns
Re: After Effects script to hide and show layer styles.
on Jul 7, 2017 at 12:52:17 pm

Managed to do this myself.
This script toggles layer styles on and off for all layers in the currently active composition as well as in all compositions nested inside it.

var activeComp = app.project.activeItem;

if (activeComp == null) {
alert("Select a composition.");
} else {
toggleLayerStyles(activeComp);
}

function toggleLayerStyles(curComp) {
for (var i = 1; i &lt;= 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

Sebastian Rasche
Re: After Effects script to hide and show layer styles.
on Jul 10, 2017 at 1:18:01 pm

How exactly do you use this? I copied the code into a .jsx file and executed it but nothing happens.
Also tried the code inside ft-toolbar but to no success. Thanks!


Return to posts index


Toms Burāns
Re: After Effects script to hide and show layer styles.
on Jul 10, 2017 at 1:52:16 pm

Just looked at the code again. Looks like creative cow post editor turned "<" into "& lt ;" . That's probably the reason why its not working for you. Fix this line -
for (var i = 1; i <= curComp.layers.length; i++) {


Return to posts index

Sebastian Rasche
Re: After Effects script to hide and show layer styles.
on Jul 10, 2017 at 2:01:22 pm

awesome! it works now and is sitting perfectly within my ft-toolbar. Thanks!


Return to posts index

Sebastian Rasche
Re: After Effects script to hide and show layer styles.
on Jul 10, 2017 at 1:21:52 pm

How exactly do I use this script?


Return to posts index

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