Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Over riding two If/Else statements

  • Over riding two If/Else statements

  • Glenn Tak

    April 14, 2020 at 7:13 pm

    I have a project which requires switching back and forth between 2 y-positions depending on the input data. Occasionally there is a need to manually adjust for a third line or special characters so I want to keep a ‘value’ option available to me.

    I have set up with 2 check boxes connected to the y-position.

    Each statement works individually but the second if/else statement seems to nullify the first

    What am I missing?

    Thanks

    Line1 = (effect("Single Line Position")("Checkbox"))
    Line2 = (effect("2 Line Position")("Checkbox"))

    if(Line1 == true)1666.5;
    else value;

    if(Line2 == true)1582.5;
    else value;

    ______________________

    “Nothing is Easy”
    Jethro Tull

  • Dan Ebberts

    April 14, 2020 at 7:37 pm

    You could combine them like this:

    Line1 = effect(“Single Line Position”)(“Checkbox”).value;
    Line2 = effect(“2 Line Position”)(“Checkbox”).value;

    if(Line1)1666.5
    else if(Line2)1582.5
    else value

    Note that Line 1 will have priority if both checkboxes are checked.

    Dan

  • Glenn Tak

    April 14, 2020 at 8:24 pm

    You are Da Man.

    Thanks. No matter how many tutorials I do, there is always something that escapes me.

    T Rex

    ______________________

    “Nothing is Easy”
    Jethro Tull

  • Glenn Tak

    April 15, 2020 at 5:55 pm

    A question….

    Does the code: Line1 = effect(“Single Line Position”)(“Checkbox”).value;

    Assume the .value is true? Is that a default for a boolean .value?

    If not, don’t know how the further code : if(Line1)1666.5: knows that the box is checked.

    I know other codes have default assumptions.

    Thanks again for the help.

    T

    ______________________

    “Nothing is Easy”
    Jethro Tull

  • Dan Ebberts

    April 15, 2020 at 6:00 pm

    Yes, the value of a checkbox evaluates to true if checked, false if unchecked.

    Dan

  • Glenn Tak

    April 15, 2020 at 6:10 pm

    Sorry for bugging you again… I think I am a little confused about

    if(Line1)1666.5

    If the checkbox for the Line 1 variable is unchecked, it would be false.

    Wouldn’t the above line then interpret that an unchecked box would result in 1666.5?

    Essentially…

    if(effect(“Single Line Position”)(“Checkbox”)==false)1666.5

    Or does a false value simply ignore the statement?

    ______________________

    “Nothing is Easy”
    Jethro Tull

  • Dan Ebberts

    April 15, 2020 at 6:20 pm

    If variable Line1 is false (corresponding checkbox unchecked), it skips the 1666.5 and moves to the else if part. If variable Line1 is true, it accepts 1666.5 as the result, and ignores the else if and else parts.

    Dan

  • Glenn Tak

    April 15, 2020 at 6:23 pm

    Thanks. That makes sense.

    I appreciate your time and wisdom.

    ______________________

    “Nothing is Easy”
    Jethro Tull

Viewing 1 - 8 of 8 posts

Log in to reply.

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