Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions After Effects script to hide and show layer styles.

  • After Effects script to hide and show layer styles.

    Posted by Toms Burāns on July 5, 2017 at 4:03 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!

    Maximus Darringer replied 7 years, 2 months ago 4 Members · 7 Replies
  • 7 Replies
  • Toms Burāns

    July 7, 2017 at 12:52 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 <= 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);
    }
    }
    }

  • Sebastian Rasche

    July 10, 2017 at 1:18 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!

  • Sebastian Rasche

    July 10, 2017 at 1:21 pm

    How exactly do I use this script?

  • Toms Burāns

    July 10, 2017 at 1:52 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++) {

  • Sebastian Rasche

    July 10, 2017 at 2:01 pm

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

  • Luis Palencia

    April 19, 2018 at 7:18 pm

    I run the script and show me this: “Unable to execute script at line 13. undefined is not an object”

  • Maximus Darringer

    May 5, 2019 at 11:22 am

    Perfect Thanks!!

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