Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › multiple if else expressions

  • multiple if else expressions

    Posted by Eman66 on July 29, 2020 at 6:26 pm

    Trying to automate color swap using color select

    looking to swap primary and secondary colors and also have the option to change either to a tertiary color

    This is what I have so far for the primary color.
    The second if statement negates the first. Believe I need something in between, but not sure what

    Any help is appreciated

    if (thisComp.layer("COLOR MASTER").effect("HOME SWAP")("Checkbox") == 0) {sampleImage([760,444],[1,1])} else
    {
    sampleImage([920,440],[1,1])
    }
    if (thisComp.layer("COLOR MASTER").effect("HOME PRI TO TER")("Checkbox") == 0) {sampleImage([760,444],[1,1])} else
    {
    sampleImage([930,536],[1,1])
    }

    Thanks Man

    Eman66 replied 6 years, 2 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    July 29, 2020 at 8:03 pm

    For a multi-conditional structure, you need an if, followed by a number of else if statements, and finally, an else. So your example might look like this:


    if (thisComp.layer("COLOR MASTER").effect("HOME SWAP")("Checkbox") == 1) {
    sampleImage([920,440],[1,1]);
    }else if (thisComp.layer("COLOR MASTER").effect("HOME PRI TO TER")("Checkbox") == 1) {
    sampleImage([930,536],[1,1]);
    }else{
    sampleImage([760,444],[1,1]);
    }

  • Eman66

    July 30, 2020 at 12:45 pm

    Thanks man. That was helpful

    Running into another issue.

    Checkbox works to swap primary and secondary colors and checkbox works to swap primary to tertiary….but if I swap primary and secondary….i’m unable to swap “new’ primary color with tertiary.

    Can there be a statement that says keep the initial swap and then add second swap?

    Hopefully I’m explaining this right

    Thanks in advance

    Thanks Man

  • Dan Ebberts

    July 30, 2020 at 2:05 pm

    I’m not sure what you’re asking. The expression can only have one result.

    Dan

  • Eman66

    July 31, 2020 at 2:06 pm

    Hey Dan

    Not sure I explained in properly

    Ended up figuring it out…needed to use && to make it work

    Final expression below

    Thanks

    target = thisComp.layer("HOME SWATCH");
    if (thisComp.layer("COLOR MASTER").effect("HOME SWAP")("Checkbox") == 1 && thisComp.layer("COLOR MASTER").effect("HOME PRI TO TER")("Checkbox") == 1)
    target.sampleImage([930,530],[1,1]) else
    if (thisComp.layer("COLOR MASTER").effect("HOME SWAP")("Checkbox") == 1 && thisComp.layer("COLOR MASTER").effect("HOME PRI TO TER")("Checkbox") == 0)
    target.sampleImage([930,450],[1,1]) else
    if(thisComp.layer("COLOR MASTER").effect("HOME SWAP")("Checkbox") == 0 && thisComp.layer("COLOR MASTER").effect("HOME PRI TO TER")("Checkbox") == 1)
    target.sampleImage([930,530],[1,1]) else
    target.sampleImage([760,444],[1,1])

    Thanks Man

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