Copy link to clipboard
Copied
I would like to get the total sum from a dynamic array. I'm not a coder but I can tinker just an FYI.
So what I'm trying to do is get the layer heights of multiple text objects so I can get the total height of the layers and resize a shape layer underneath to the total height of the text layers. I was able to find code to get the max width of the text layers but don't know how to get the total height. Below is the for loop to get the width:
It works for me. Did you modify the expression at all, or did you paste it in directly from my post?
Yes, I had modified my code. I must have missed something. It does work. THANK YOU!
Copy link to clipboard
Copied
This should work:
keyword = "Text";
textListWidth = [];
y = 0;
for(i = 1; i <= thisComp.numLayers; i++){
layerPath = thisComp.layer(i);
layerWidth = layerPath.sourceRectAtTime().width;
layerHeight = layerPath.sourceRectAtTime().height;
if(layerPath.name.match(keyword)) {
textListWidth.push(layerWidth);
y += layerHeight;
}
}
x = Math.max.apply(null, textListWidth);
[x, y]
Copy link to clipboard
Copied
Thank you for the reply but it's not seeming to add all the layer heights together. I think it's taking one height.
Copy link to clipboard
Copied
It works for me. Did you modify the expression at all, or did you paste it in directly from my post?
Copy link to clipboard
Copied
Yes, I had modified my code. I must have missed something. It does work. THANK YOU!
Copy link to clipboard
Copied
If you want to wrap shape layer boxes around multiple layers, my (paid) tool Pins & Boxes can also be very helpful:
It creates all the expressions for you and you can create pretty complex layouts with it in a quick and easy way without worrying about the code.