-
Comparing Values from infinite amount of Layers
Hi again,
i am going through a little experiment here where i wondered if it is possible to have an infinite range of layers as a part of an expression. The expression in question is the following for scale property of a text layer:
txt = thisComp.layer(index).text.sourceText.split(“r”);
max = thisComp.layer(“CONTROLLER”).effect(“characters”)(“Slider”);
n = 0
for (i = 0; i < txt.length; i++) n = Math.max(n, txt[i].length);if (n>max)
{[(value[0]/n)*max,(value[1]/n)*max]}
else
{value}This is an auto scaler that will automatically reduce the size of a text layer when reaching a max characters value (to be set by a slider).
Now say if i duplicate this layer, each scale expression will just consider its own layer’s source text as a basis for the calculation. Would it be possible to modify the above code so that each time the text layer is duplicated, the expression will compare the values from all duplicates and give the smallest value?
For instance, say the above expression sits on the scale property of layer 7. Now if i create a layer 8 by duplicating layer 7, the expression should look at both layer 7 and 8 and compare their values to find the smallest. If i duplicate yet again and create a layer 9, the expression should look at the results from layer 7, 8 and 9… and so on, and so on…
i am thinking the solution might either be terribly simple or terribly complicated. I just can’t figure it out. Obviously it would involve Math.max at some point. But the addressing part of the layers is a mind job.