Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Show or hide a layer in After Effects (Without using Opacity)

  • Show or hide a layer in After Effects (Without using Opacity)

    Posted by Andy Troz on August 5, 2013 at 3:32 pm

    Hello again!

    Sorry for the constant questions, but is there a script or expression to show or hide a layer in After Effects (via the “eye” checkbox)?

    Best,
    Andy.

    Dan Ebberts replied 10 years, 5 months ago 3 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    August 5, 2013 at 5:29 pm

    You can’t do it it with expressions, but with scripting it would be like this:

    myLayer.enabled = false;

    Dan

  • Geof Gagnon

    March 13, 2016 at 6:40 am

    Hey Dan, I’m currently having a problem and I can’t get this expression to work. My syntax is:


    var path = "~/Desktop/fireball.png";

    var io = new ImportOptions(File(path));

    if (io.canImportAs(ImportAsType.FOOTAGE)){
    io.importAs = ImportAsType.FOOTAGE;
    io.sequence = false;
    io.forceAlphabetical = true;

    var sequence = app.project.importFile(io);
    sequence.name = "importA";
    }

    var myComp = null; // assume the worst
    for (var i = 1; i <= app.project.numItems; i++){
    if ((app.project.item(i).name == "importA")){
    myComp = app.project.item(i);
    break;
    }
    }
    if (myComp != null){
    app.project.activeItem.layers.add(myComp);

    }

    no matter where I put the expression to disable the layer, it doesn’t seem to do it’s job. Any ideas? Thanks.

  • Dan Ebberts

    March 13, 2016 at 7:47 am

    Sorry–I’m confused. You mention an expression, but you posted a script. What is that you’re trying to do exactly?

    Dan

  • Geof Gagnon

    March 13, 2016 at 7:43 pm

    Sorry, it’s actually a script. On button click I create a solid, add particle world to it, then import a png file, add it to the composition, and then I’d like to hide it. I believe the reference to the .png by the time it reaches the composition is myComp. But I’m unable to disable it.

  • Dan Ebberts

    March 13, 2016 at 8:44 pm

    Ah, OK–try this:

    var myLayer = app.project.activeItem.layers.add(myComp);
    myLayer.enabled = false;

    Dan

  • Geof Gagnon

    March 13, 2016 at 8:49 pm

    Worked like a charm, you’re a king among men Dan.
    If you don’t mind me asking, what was the problem? It just needed to be assigned to a variable?

  • Dan Ebberts

    March 13, 2016 at 9:34 pm

    Actually, you could have done it in one step like this:

    app.project.activeItem.layers.add(myComp).enabled = false;

    which would create the layer and disabled it. The key is that you have to apply the .enabled = false to a layer object. I’d probably first put the layer object into a variable (like my example) and then disable it, just for clarity.

    Dan

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