Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions break in source text

  • Gyula Bodonyi

    January 3, 2019 at 9:40 am

    Dear Dan!

    I have a question about line breaks via script. I want to write a script that makes a text layer with an expression. It’s all good, and working but if I want to make line breaks in the final result, the break only appears in my expression. Do you have any idea?

    myComp.layer("").text.sourceText.expression =
    "try{"+"\r"+
    "L=parent;"+"\r"+
    "t=time-L.inPoint;"+"\r"+
    "tF=timeToFrames(t);"+"\r"+
    "t=timeToCurrentFormat(t);"+"\r"+
    "t+ ' \r ' +tF;"+"\r"+ // that would be the problematic part. It breaks the expression, not the final result.
    "}catch(e){"+"\r"+
    "'select a parent layer'"+"\r"+
    "}"

  • Andy Engelkemier

    May 27, 2021 at 6:37 pm

    For anyone else that came here, like me, to find that answer, but found this to be more complex than they were looking for, and Maybe some of the expressions are using the older language?

    I wanted the source text of one layer to be two lines, and I’m using Essential properties for my titles (aka master properties?)

    It should be entered like this: “something\relse”

    which will create something and else on two different lines. the \r is a line return. And since it’s all in quotes you can’t uses spaces or those will be included.

    Some of the other examples used in this thread, they are assigning variables to values that will be the text string. It’s a Little confusing for newer people because they are numbers, but stored as text. And that’s why I thought it was more confusing than needed, for this. But this was the first answer that came up on google. Correct, but took me a couple minutes, and a few variations of trying \ and / with quotes in different places till I got what I needed. I always find it difficult to know the syntax needed and have never really found a great way to look it up other than just finding a similar example to what you need. But with the language issue, that’s a pain.

    Just today I had a title I used that I purchased. But when bringing it into another ae file, it had an error. It was just that the if/else statement was in a single line and nothing more. All I did with split it up on multiple lines and the error was gone. And that was just a complete guess because I remembered someone saying something like that.

    So hopefully this answer helps the next person who comes along after searching google.

Page 2 of 2

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