-
For loop that index references the name of a layer skipping layers otherwise
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.
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
Some contents or functionalities here are not available due to your cookie preferences!This happens because the functionality/content marked as “Vimeo framework” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.
