Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Adding expression via script – readability question

  • Adding expression via script – readability question

    Posted by Bryan Woods on April 1, 2013 at 6:56 pm

    So i’ve been creating scripts for a while now and a lot of them basically put in expressions to selected layers. But i’ve been having issues with laying out the expression in the scripts. I end up having to compress the expression down into really long “sentences”, with all of the indenting and spacing removed so that the script puts the expression in properly. But I’d like to see the expression in a readable format like I originally wrote it. Is there a way to do this when using a script to add an expression to a parameter of a layer? I’ve attached a screen shot hopefully showing what I’m talking about.

    First screenshot shows how I have to write the expression within the script,

    second screenshot shows how it was originally written, and how I’d like to be able to see it in the expression on the layer when in AE.

    Bryan Woods replied 13 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    April 1, 2013 at 7:39 pm

    There are a couple of ways to do it, the simplest is probably to just use triple quotes to create an expression variable:


    var myExpr =

    """transition = 20;

    if (marker.numKeys<2){
    tSecs = transition / (1 / thisComp.frameDuration);
    linear(time, inPoint, inPoint + tSecs, -1, -2.5) + linear(time, outPoint - tSecs, outPoint, 2.5, 4)
    }else{
    linear(time, inPoint, marker.key(1).time, -1, -2.5) + linear(time, marker.key(2).time, outPoint, 2.5, 4)
    }""";

    Dan

  • Bryan Woods

    April 1, 2013 at 8:37 pm

    Aaaah wonderful! MAN that makes reading the expression so much nicer. Thank you for the tip! Now I need to go back and update all my scripts with this.

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