Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions how to combine two or more expressions for a same parameter.

  • how to combine two or more expressions for a same parameter.

    Posted by Roberto Mata on January 25, 2015 at 5:41 pm

    Hello,

    Let’s see if I succeed to explain my case.
    I’m rigging a 2D character’s head for a horizontal AND vertical turn.

    HORIZONTAL:

    – HORIZONTAL TURN comp is set to 20 frames, then time remapped, then tied to a HEAD_TURN_HOR slider control within a master HEAD_CTRL.
    a=thisComp.layer("HEAD_CTRL").effect("HEAD_TURN_HOR")("Slider");
    framesToTime(a)

    – BLINK POSITIONS (x4) comps (closed, sibylline, neutral and surprise) are time remapped and tied to the HORIZONTAL TURN comp time remap. thisComp.layer("HORIZONTAL TURN").timeRemap
    Plus, I’ve set an expression for their opacity and tied it to a BLINK_HOR slider control within the master HEAD_CTRL: Closed (0 to 9), Sibylline (10 to 19), Neutral (20 to 29) and Surprise (30 to 39).
    a=thisComp.layer("HEAD_CTRL").effect("BLINK_HOR")("Slider");
    if((a>=20)&&(a<30)) 100 else 0

    – Up to 11 MOUTH VARIATIONS comps are time remapped and tied to the HORIZONTAL TURN comp time remap.
    thisComp.layer("HORIZONTAL TURN").timeRemap
    Then, same as with the blinks, set an expression for their opacity and tied it to a MOUTHS_HOR slider control within the master HEAD_CTRL.
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_HOR")("Slider");
    if((a>=90)&&(a<100)) 100 else 0

    VERTICAL:

    (same as horizontal)

    So I’ve ended with this MASTER HEAD CTRL with 6 sliders inside:

    1- HEAD_TURN_HOR (controls HORIZONTAL TURN, BLINKSx4 and MOUTHSx11 time remaps)
    2. BLINK_HOR (controls the visibility of each of the 4 blinks)
    3. MOUTHS_HOR (controls the visibility of each of the 11 mouths)
    4. HEAD_TURN_VER
    5. BLINK_VER
    6. MOUTHS_VER

    I intended to overlap both heads (H&V) at frame 10, the only moment they’re identical, and create a 7th control, a CHECKBOX, so that when the HORIZONTAL was being animated, the vertical’s opacity would be set to 0 and vice versa. But it seems it’s not that simple.

    I can’t control the opacity of the comps by creating an expression in the sliders, so I guess I would need to create an expression for opacity within the HORIZONTAL TURN, BLINKS (X4) AND MOUTHS (X11) comps. And they already have an expression to control their visibility.

    Please, any suggestion?
    THANKS!

    Roberto Mata replied 11 years, 7 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    January 25, 2015 at 7:04 pm

    It might be structured something like this:


    cb = thisComp.layer("HEAD_CTRL").effect("HORIZONTAL")("Checkbox");
    if (cb == 1){
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_HOR")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }else{
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_VERT")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }

    Dan

  • Roberto Mata

    January 26, 2015 at 11:01 am

    Thanks Dan,

    I’m still trying to interpret your suggestion (i’m afraid i dont’t have the required after effects or expressions command).

    If i’m not mistaken, you’re suggesting that I write that code for the opacity of every layer or comp which is already controlled by a slider (every MOUTH and BLINK position, as well as something similar for the vertical and horizontal HEAD TURNS), in such a way that when the checkbox is ON the horizontal comps affected are 100% opacity and the vertical ones 0%, right?

    I will try that out. Hope I did get it well.
    THANKS

  • Roberto Mata

    January 26, 2015 at 4:17 pm

    It worked smoothly, Dan.
    I’m so thankful!

    However, I’ve noticed that I have to express horizontal AS WELL AS vertical opacities (cb==0), which I find weird, because the if/else expression for horizontal opacities (or its negation, in a certain way) should automatically enable the vertical ones.

    cb = thisComp.layer("HEAD_CTRL").effect("HORIZONTAL")("Checkbox");
    if (cb == 0){
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_VER")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }else{
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_HOR")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }

    Anyway, you saved my day.
    Thanks again.

  • Roberto Mata

    January 26, 2015 at 7:40 pm

    Nah, it doesn’t work for the LIDS and MOUTHS.

    It does work for the comps which opacities hadn’t been expressed yet (pupils, eyebrows and head turns), though.
    That’s why I thought it would work for every other layer.

    I’m pasting the basic layers and expressions of my project, so that hopefully someone can point out what i’m doing wrong:

    1. HEAD_CTRL (null):

    – HOR/VER (checkbox)
    – HEAD_TURN_HOR (slider)
    – BLINK_HOR (slider)
    – MOUTHS_HOR (slider)
    – HEAD_TURN_VER (slider)
    – BLINK_VER (slider)
    – MOUTHS_VER (slider)

    2. V_MOUTHS_U (comp): parent: HEAD_CTRL

    – Expression: Time Remap
    thisComp.layer("V_HEADTURN").timeRemap
    – Expression: Opacity
    cb = thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if (cb == 0){a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_VER")("Slider");
    if((a>=0)&&(a<10)) 100 else 0
    }else{
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_HOR")("Slider");
    if((a>=0)&&(a<10)) 100 else 0
    }

    (same for 10 more vertical mouths variations)

    13. V_EYEBROWS (comp): parent: HEAD_CTRL

    – Expression: Time Remap
    thisComp.layer("V_HEADTURN").timeRemap
    – Expression: Y position
    a=thisComp.layer("HEAD_CTRL").effect("BLINK_VER")("Slider");
    if((a>=30)&&(a<40)) value else value+4

    – Expression: Opacity
    cb=thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if(cb==0) 100 else 0

    14. V_LIDS_CLOSED (comp): parent: HEAD_CTRL

    – Expression: Time Remap
    thisComp.layer("V_HEADTURN").timeRemap
    – Expression: Opacity
    cb = thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if (cb == 0){a=thisComp.layer("HEAD_CTRL").effect("BLINK_VER")("Slider");
    if((a>=0)&&(a<10)) 100 else 0
    }else{
    a=thisComp.layer("HEAD_CTRL").effect("BLINK_HOR")("Slider");
    if((a>=0)&&(a<10)) 100 else 0
    }

    (same for 3 other vertical LIDS variations)

    18. V_R_PUPIL (comp): parent: PUPIL_R_CTRL

    – Expression: Time Remap
    thisComp.layer("V_HEADTURN").timeRemap
    – Expression: Opacity
    cb=thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if(cb==0) 100 else 0

    19. V_L_PUPIL (comp): parent: PUPIL_L_CTRL

    – Expression: Time Remap
    thisComp.layer("V_HEADTURN").timeRemap
    – Expression: Opacity
    cb=thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if(cb==0) 100 else 0

    20. PUPIL_R_CTRL (shape) parent: EYE_R_CTRL
    21. PUPIL_L_CTRL (shape) parent: EYE_L_CTRL
    22. EYE_R_CTRL (shape) parent: H_HEADTURN
    23. EYE_L_CTRL (shape) parent: H_HEADTURN

    24. H_MOUTH_U (comp): parent: HEAD_CTRL

    – Expression: Time Remap
    thisComp.layer("H_HEADTURN").timeRemap
    – Expression: Opacity
    cb = thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if (cb == 1){a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_HOR")("Slider");
    if((a>=0)&&(a<10)) 100 else 0
    }else{
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_VER")("Slider");
    if((a>=0)&&(a<10)) 100 else 0
    }

    (same for 10 more horizontal mouth variations)

    35. H_EYEBROWS (comp): parent: HEAD_CTRL

    – Expression: Time Remap
    thisComp.layer("H_HEADTURN").timeRemap
    – Expression: Y position
    a=thisComp.layer("HEAD_CTRL").effect("BLINK_HOR")("Slider");
    if((a>=30)&&(a<40)) value else value+4

    – Expression: Opacity
    cb=thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if(cb==0) 100 else 0

    36. H_LIDS_CLOSED (comp): parent: HEAD_CTRL

    – Expression: Time Remap
    thisComp.layer("H_HEADTURN").timeRemap
    – Expression: Opacity
    cb = thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if (cb == 1){a=thisComp.layer("HEAD_CTRL").effect("BLINK_HOR")("Slider");
    if((a>=0)&&(a<10)) 100 else 0
    }else{
    a=thisComp.layer("HEAD_CTRL").effect("BLINK_VER")("Slider");
    if((a>=0)&&(a<10)) 100 else 0
    }

    (same for 3 more horizontal LIDS variations)

    40- H_R_PUPIL (comp): parent: PUPIL_R_CTRL

    – Expression: Time Remap
    thisComp.layer("H_HEADTURN").timeRemap
    – Expression: Opacity
    cb=thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if(cb==1) 100 else 0

    41. H_L_PUPIL (comp): parent: PUPIL_L_CTRL

    – Expression: Time Remap
    thisComp.layer("H_HEADTURN").timeRemap
    – Expression: Opacity
    cb=thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if(cb==1) 100 else 0

    42. V_HEADTURN (comp): parent: HEAD_CTRL

    – Expression: Time Remap
    a=thisComp.layer("HEAD_CTRL").effect("HEAD_TURN_VER")("Slider");
    framesToTime(a)

    – Expression: Opacity
    cb=thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if(cb==0) 100 else 0

    43. H_HEADTURN (comp) parent: HEAD_CTRL

    – Expression: Time Remap
    a=thisComp.layer("HEAD_CTRL").effect("HEAD_TURN_HOR")("Slider");
    framesToTime(a)

    – Expression: Opacity
    cb=thisComp.layer("HEAD_CTRL").effect("HOR/VER")("Checkbox");
    if(cb==1) 100 else 0

    Thanks for the help!

  • Roberto Mata

    January 27, 2015 at 3:40 pm

    Finally got it!

    Let me share what I was doing wrong:

    Dan gave me this expression

    cb = thisComp.layer("HEAD_CTRL").effect("HORIZONTAL")("Checkbox");
    if (cb == 1){
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_HOR")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }else{
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_VER")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }

    Which I read in the following way: If the checkbox (HORIZONTAL) is ON, it enables the slider for horizontal mouths opacities (MOUTHS_HOR). Else, with the checkbox OFF, it enables the slider for vertical mouths slider (MOUTHS_VER).

    The problem was I pasted the variation in every opacity paramater affected.

    So for the S shape of the mouth i.e. I had:

    H_MOUTHS_S

    Expression: Opacity
    cb = thisComp.layer("HEAD_CTRL").effect("HORIZONTAL")("Checkbox");
    if (cb == 1){
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_HOR")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }else{
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_VER")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }

    V_MOUTHS_S

    Expression: Opacity
    cb = thisComp.layer("HEAD_CTRL").effect("HORIZONTAL")("Checkbox");
    if (cb == 0){
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_VER")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }else{
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_HOR")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }

    So I was, somehow, replicating the inverse order. So for checkbox ON I had one expression that enabled HORIZONTAL mouths AND, because of the expression variation for V_MOUTHS_S, I was enabling ANOTHER set of HORIZONTAL mouths in the position of the vertical ones(!), since it enables its ELSE and there will always be one set of mouths with opacity 100%

    Finally I figured out the solution, of course based on Dan’s premise, idea and code.

    H_MOUTHS_S

    Expression: Opacity
    cb = thisComp.layer("HEAD_CTRL").effect("HORIZONTAL")("Checkbox");
    if (cb == 1){
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_HOR")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }else 0

    V_MOUTHS_S

    Expression: Opacity
    cb = thisComp.layer("HEAD_CTRL").effect("HORIZONTAL")("Checkbox");
    if (cb == 0){
    a=thisComp.layer("HEAD_CTRL").effect("MOUTHS_VER")("Slider");
    if((a>=90)&&(a<100)) 100 else 0
    }else 0

    Thank you, Dan. You were very helpful and force me to expand (just a little) my understanding of expressions.

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