Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions try catch try catch try catch

  • try catch try catch try catch

    Posted by Scott Mcgee on March 20, 2017 at 10:10 pm

    try{
    thisComp.layer(index+1).effect(“bar_index”)(“Slider”).value +1;
    }catch(err){
    thisComp.layer(index+2).effect(“bar_index”)(“Slider”).value +1;
    }

    This does exactly what I want.

    Now…

    Is there a way I can add more

    thisComp.layer(index+3).effect(“bar_index”)(“Slider”).value +1;
    thisComp.layer(index+4).effect(“bar_index”)(“Slider”).value +1;

    I tried a for loop with no success. I simply got the index of the layer rather than just +1 (So I got 6 +1 if it was the 6th layer).

    Unless someone knows a for loop that can incorporate this, is there anyway I can try catch, try catch. I can’t imagine there being a gap of more than 3 or 4, but if there’s an infinite way that would be cool.

    Scott Mcgee replied 9 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 20, 2017 at 10:32 pm

    I haven’t tested it, but something like this should find the next layer with that effect (if there is one):


    val = null;
    for ( i = index+1; i <= thisComp.numLayers; i++){
    try{
    val = thisComp.layer(i).effect("bar_index")("Slider").value +1;
    break;
    }catch(err){
    }
    }
    if (val != null){ // found one
    // do stuff
    }else{ // no luck
    // do other stuff
    }

    Dan

  • Scott Mcgee

    March 20, 2017 at 10:37 pm

    As always, you’re a true star.

    3 days trying to figure this out, and you got it in one.

    Thank you Sir

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