Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression needed: IF source text of textlayer A is negative number THEN opacity of layerB is 0, opacity of layer C is 100

  • Expression needed: IF source text of textlayer A is negative number THEN opacity of layerB is 0, opacity of layer C is 100

    Posted by Simon Robbrecht on June 10, 2015 at 1:27 pm

    Hi,

    I am looking for an easy way to speed up a daily job (generating a number of comps based on info filled out in textlayers in another comp).

    All data are filled out in a master comp. If I nest this comp and mask only the fields I need for every distinct comp, rendering takes ages.

    I used expressions to fill out the textlayers (referring to the textsource in the mastercomp). This speeds up rendering a lot compared to masked nested comps.

    However, all comps also contain arrows (red down or green up) for negative and positive values.
    So for these layers, I am in need of an expression for the opacity that looks at the sourcetext of a textlayer. If this source starts with a “-“, then the opacity of the red arrow should be 100, the opacity of the green arrow 0.
    If no “-” is present, the other way round.

    I am also looking for an easy way to “choose” between a number of flags.
    Could I (or you!) come up with a method of selecting a flag (through opacity i guess) via an expression controller of some sort in the master comp and having another corresponding layer pop up (opacity) in another comp?

    All help, hints, tips and tricks much appreciated!

    Thanks

    Simon

    Simon Robbrecht replied 11 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    June 10, 2015 at 4:20 pm

    If you want a layer to be visible if the text layer starts with “-“, you could do it like this:

    txt = thisComp.layer(“text layer”).text.sourceText;
    if (txt.length > 0 && txt[0] == “-“) 100 else 0

    If you want it to be invisible, it would be:

    txt = thisComp.layer(“text layer”).text.sourceText;
    if (txt.length > 0 && txt[0] == “-“) 0 else 100

    I’m not sure what you’re asking in the part about “flags”.

    Dan

  • Simon Robbrecht

    June 11, 2015 at 1:24 pm

    Hi Dan,

    Thanks a lot for the expressions, they work great!

    I used it for the flag part as well. In the master comp I added a text layer in which I type a country code.
    In the rendercomp I inserted a bunch of layers with the flags of different countries.

    See this example for the opacity of the flag of Switzerland in my rendercomp

    txt=comp(“__MASTER”).layer(“EUROP02land”).text.sourceText;
    if (txt.length > 0 && txt == “ch”) 100 else 0

    Unfortunately, render times are still too long… I got it down from 13 minutes to 2 mins 40 seconds but this is still too long for our workflow.

    But thanks anyway!

    s

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