Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Just because I’m curious… Put an expression into a var

  • Just because I’m curious… Put an expression into a var

    Posted by Scott Mcgee on January 12, 2018 at 8:36 am

    I realised I sometimes use an expression more than once in quite a few if/else statements. I’m just used to it being bulky, but never thought about putting the repeated expression into a variable.

    a = 1;
    fad = eval(“if (time < (inPoint + outPoint)/2){ease(time,inPoint,inPoint+a,0,100);} else 0;”)
    if(thisLayer.name == “Station”){
    fad;
    } else 0;

    although this is just for testing purposes, this worked nicely.

    but this doesn’t

    a = 1;

    fad = eval(“if (time < (inPoint + outPoint)/2){
    ease(time,inPoint,inPoint+a,0,100);
    } else 0;”)

    if(thisLayer.name == “Station”){
    fad;
    } else 0;

    I kinda know why it doesn’t work, but is there a way to make the second one work?…As it would be nice just to know how to in the future. I’ve seen a few possible ways that people have put, but I’ve had no success.

    Scott Mcgee replied 8 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Andrei Popa

    January 12, 2018 at 9:52 am

    Andrei to the rescue. In order to have a multiline expression between quotes, you need to use triple quotes. This should work:
    a = 1;

    fad = eval("""if (time < (inPoint + outPoint)/2){
    ease(time,inPoint,inPoint+a,0,100);
    } else 0;""")

    if(thisLayer.name == "Station"){
    fad;
    } else 0;

    Andrei
    My Envato portfolio.

  • Scott Mcgee

    January 12, 2018 at 10:33 am

    face and palm have just met.

    Thank you

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