Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Disable a Composition Programmatically

  • Disable a Composition Programmatically

    Posted by greg humphrey on March 29, 2024 at 1:48 am

    Is there a way to disable a Composition Programmatically?

    It can be done with layers, i.e. myLayer.enabled=false .

    But doesnt seem we can do the same thing on a comp, i.e. myComp.enabled=false.

    They both have the eyeball, you’d think this world work on both.

    Same goes with setting opacity on the comp, i.e. theComp.opacity=0; , that doesnt work either.

    Am I just not getting the syntax correct?

    Levi Borland replied 1 year, 1 month ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    March 29, 2024 at 3:41 am

    What eyeball are you talking about for comps? Comps as layers have layer eyeballs, but comps in the project bin don’t have eyeballs. If you’re talking about a comp layer, then to access it’s eyeball, you have to reference it as a layer.

  • greg humphrey

    March 29, 2024 at 3:33 pm

    Dan is the best!

    It’s the “Comps as layers have layer eyeballs” I was referring to. What I didnt realize was programmatically I can call a comp as a layer and access the properties that way.

    Something like this works.

    var theComp = app.project.item(i)

    for(var k=1; k<=theComp.numLayers; k++) {

    var theLayer = theComp.layer(k)

    if(theLayer.name==”myCompAsALayer”) {

    theLayer.enabled=false;

    }

    }

  • Levi Borland

    March 30, 2024 at 2:56 am

    You can also use expression controllers for this. Precomp the comp that you want to turn on and off. Then create an empty layer and apply a checkbox controller. Write an if/else expression on the precomp for opacity. If checkbox is checked, opacity 100, if unchecked – opacity 0.

    Something like this…

    if(thisComp.layer(“Adjustment Layer 1”).effect(“Checkbox Control”)(“Checkbox”)==0)0 else 100

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