ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

For loop that index references the name of a layer skipping layers otherwise

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott McGee
For loop that index references the name of a layer skipping layers otherwise
on Mar 18, 2017 at 1:29:49 pm
Last Edited By Scott McGee on Mar 20, 2017 at 11:30:09 am

So I've built a bar graph. This bar graph will be used by staff members who have minimal knowledge of after effects and like boxes that you fill out and hit a button that will automatically make this happen. So I have built my own UI panel that does this with edit boxes that will allow for changes. This is tested and works.

But the problem is, they don't always want 5 bars, sometimes they want 3 or 10 for example.

So what I want it to do. If I duplicate a shape layer (bar), it will change its position to sit next to the next one.

I've seen this tutorial that is pretty much what I want it. I've written a script that will update or duplicate the layer. So I don't need to worry about the array feature.

https://vimeo.com/57879355

Only one issue I have with this. That I'm hoping someone my be able to help with.

var myIndex = effect("bar_index")("Slider").value;
var tOrigWidth = (myIndex-1) * thisLayer.source.width *1.1;
[tOrigWidth, value[1]];


because I will be putting layers underneath these (Background image and graphical element). This slider control is helpful, but I want it too automatically look at the layer below and change The sliders control value + 1

This works, but only for the layer directly below.

thisComp.layer(index+1).effect("bar_index")("Slider").value + 1;

I need it to reference the next one in the comp if I decide to place something between the layers. For example.

1: Controller
2: Text 4
3: Text3
4: Bar 6
5: Text 2
6: Bar 5
7: Bar 4
8: Bar 3
9: Bar 2
10: Bar 1
11: BKGD


(So 'Bar 6', with the current expression breaks producing an error. I want it to look down the list and find the next one 'Bar 5')

I've taken a look at a lot of threads that match name of layer, but I have had no success in finding an expression that works. I know the index will have to be something on the lines of thisComp.Layer(i), using the (i) to index all the layers, but I can't get it to find the next one.

I also need too take into account that when I duplicate my layers name is going to change bar1,bar2,bar3.

findName = "Bar";
for (i =index; i <=thisComp.numLayers; ++i) {
if (thisComp.layer(i).name.indexOf(findName) != -1) {
effect("bar_index")("Slider").value + 1;
break;
}
}


This works, but it's now referencing the number of layers. I'm nearly there.

Any suggestions would be greatful



Return to posts index

Scott McGee
Re: For loop that index references the name of a layer skipping layers otherwise
on Mar 20, 2017 at 4:59:08 pm
Last Edited By Scott McGee on Mar 20, 2017 at 5:28:23 pm

Still struggling with this,

But to update...

var name = "Bar";
for (i =1; i <=thisComp.numLayers; ++i) {
if(thisComp.layer(i).name){
i;
break;
}
}


I thought the expression was referring to the name Bar, but when I deleted this and left it blank. It still worked, which is fine. Except I still have the problem of this



I want the expression to still +1 my slider, so it shifts the position, but I want it to ignore any layer inbetween so I don't get the gap.


Return to posts index

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