Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions ExtendScript – add expression to opacity property

  • ExtendScript – add expression to opacity property

    Posted by Paul Connors on November 1, 2016 at 3:49 pm

    Hello,

    I’m currently writing a script and am stuck on trying to automatically add an expression to a specific composition. Currently my script creates a new comp named: “Precomp1”. It also creates another composition within “Precomp1” named: “Item 1”. I’m trying to then automatically add an expression to the opacity property for “Item 1.” Here is my current code:

    var MasterComp = app.project.activeItem;
    var Precomp1 = app.project.items.addComp("Precomp1", 1920, 1080, 1, 60, 29.97);
    MasterComp.layers.add(Precomp1);

    var Item001Comp = app.project.items.addComp("Item 1", 1920, 1080, 1, 60, 29.97);

    Precomp1.layers.add(Item001Comp);

    Any ideas?

    Thank you!

    Paul Connors replied 9 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    November 1, 2016 at 4:45 pm

    Like this, I think:

    var MasterComp = app.project.activeItem;
    var Precomp1 = app.project.items.addComp(“Precomp1”, 1920, 1080, 1, 60, 29.97);
    MasterComp.layers.add(Precomp1);
    var Item001Comp = app.project.items.addComp(“Item 1”, 1920, 1080, 1, 60, 29.97);
    var myLayer = Precomp1.layers.add(Item001Comp);
    myLayer.property(“Opacity”).expression = “75”;

    Dan

  • Paul Connors

    November 1, 2016 at 6:17 pm

    Hi Dan. That’s fantastic! Thank you very much. I’m able to get it to work with a simple expression like “75” or even “wiggle(2,50)” but I’m struggling to add a more complex expression to that opacity property. I have an expression from another project I’m trying to incorporate here. That working expression looks like this:

    C = comp("Master");
    ctrl = C.layer("Controls").effect("Slider Control")("Slider");
    L = C.layer(thisComp.name);
    val = Math.round(ctrl.valueAtTime(time+L.startTime));
    if (val == index) 100 else 0


    Do you know how would go about incorporating that to opacity expression help you offered above?

    Thanks!

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