ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

try catch try catch try catch

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott McGee
try catch try catch try catch
on Mar 20, 2017 at 10:10:02 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.


Return to posts index

Dan Ebberts
Re: try catch try catch try catch
on Mar 20, 2017 at 10:32:03 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



Return to posts index

Scott McGee
Re: try catch try catch try catch
on Mar 20, 2017 at 10:37:53 pm

As always, you're a true star.

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

Thank you Sir


Return to posts index

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