ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Control Error Expression

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tiago Cav
Control Error Expression
on Jun 3, 2015 at 1:54:56 pm
Last Edited By Tiago Cav on Jun 3, 2015 at 2:08:41 pm

I'm using an expression with "sourceRectAtTime ()" in the Scale of a text. Works correctly, but when I turn out the text completely, the expression results in an error. Because try to find a value in "sourceRectAtTime ()" which is 0, but my expression is a calculation that divides a value by "sourceRectAtTime ()". And can not divide a value by 0, this is the error.

Is possible use a try/catch block which will test a block of code for errors while executing; if an error in the try block occurs, then the catch block is executed.

But I do not understand how it applies.

  • I want to know how to use it for use when no letters in the text layer, not cause mistake, just turn off the expression.


  • I want to know, also:

  • How to represent "None" in an expression?


  • I need use this Expression, adding a control of Errors.
    s = 70/sourceRectAtTime().height * 100;
    [s,s]


    Thanks.


    Return to posts index

    Kevin Camp
    Re: Control Error Expression
    on Jun 3, 2015 at 4:39:40 pm

    there's a few ways to handle it. try this:

    h = sourceRectAtTime().height;
    if (h=0) s=0 else s = 70/h*100;
    [s,s]


    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW


    Return to posts index


    Kevin Camp
    Re: Control Error Expression
    on Jun 3, 2015 at 10:55:31 pm

    sorry Tiago, I made a mistake in the syntax.

    try this:

    h = sourceRectAtTime().height;
    if (h==0) s=0 else s = 70/h*100;
    [s,s]


    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW


    Return to posts index


    Tiago Cav
    Re: Control Error Expression
    on Jun 4, 2015 at 2:08:37 am

    Awesome! Work perfectly.

    How to represent "None" in an expression?

    Thank you so much!


    Return to posts index

    Kevin Camp
    Re: Control Error Expression
    on Jun 4, 2015 at 5:33:19 pm

    you can usually represent none with empty quotes: "" or ''

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW


    Return to posts index

    Tiago Cav
    Re: Control Error Expression
    on Jun 4, 2015 at 7:16:28 pm

    Thank you!


    Return to posts index

    << PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
    © 2017 CreativeCOW.net All Rights Reserved
    [TOP]