Copier le lien dans le Presse-papiers
Copié
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!
Copier le lien dans le Presse-papiers
Copié
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]
Copier le lien dans le Presse-papiers
Copié
Thank you for the reply but it's not seeming to add all the layer heights together. I think it's taking one height.
Copier le lien dans le Presse-papiers
Copié
It works for me. Did you modify the expression at all, or did you paste it in directly from my post?
Copier le lien dans le Presse-papiers
Copié
Yes, I had modified my code. I must have missed something. It does work. THANK YOU!
Copier le lien dans le Presse-papiers
Copié
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.
Préparez-vous ! Une expérience Adobe Community améliorée arrive en janvier.
En savoir plus