-
Add up the heights of however many layers are present?
Hi!
I’m building a template for which I need to know the total of all the text layers’ heights in pixels, by adding up all their
sourceRectAtTime(0).heightvalues. The template consists of a variable number of text layers, which are arranged on multiple lines, centered horizontally. Just a standard title screen basically.I have a general idea of how the logic could work, but I’m not quite sure where to start with this. The number of lines of text will vary, which the template must accommodate automatically. Ultimately I will use the total height of all the lines of text to calculate how to center the block of multiple text layers vertically.
I’ve named all my text layers like, “TXT – name“. I use
name.split(" - ")[0]to detect the string “TXT,” to determine which layers are designated as text layers.I believe I can use the code above as a basis to count how many “TXT” layers exist. Then I can use that value to tell AE which layer indexes’ heights need to be added up. Something like,
If there are 2 Text layers detected, add up the heights of layer 1 + layer 2
If there are 4 Text layers detected, add up the heights of layer 1 + layer 2 + layer 3 + layer 4
etc…
Thanks