# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Get Largest Rectangle Path Size From Different Shape Layers

• # Get Largest Rectangle Path Size From Different Shape Layers

Posted by on March 28, 2024 at 9:22 pm

I need to grab layer(“A”+n).content(“Rectangle Path 1”).size[0] from each shape layer starting from A1, A2, etc and set a Point Control to the maximum number, regardless of how many shapes with rectangles I add. Is this possible? I imagine there’s a for loop alongside a try catch to see if the layer has a Rectangle Path 1, but I’m having trouble putting everything together.

3 Members · 3 Replies
• 3 Replies
• ### Dan Ebberts

March 28, 2024 at 9:34 pm

The name testing could be more robust, but this might get the job done for you. I’m not sure why you’d use a point control if you’re only interested in the x dimension, but here it is:

`max = 0;for (i = 1; i <= thisComp.numLayers; i++){  if (thisComp.layer(i).name[0] == "A"){    try{      x = thisComp.layer(i).content("Rectangle 1").content("Rectangle Path 1").size[0];      max = Math.max(max,x);    }catch(e){    }  }}[max,0]`
• ### Shane Starnes

April 1, 2024 at 3:28 pm

Ah, good point about the point control, my idea was morphing as I typed the original message

😅 Works flawlessly though. As always, great work Dan and thank you for the assist!

• ### Brie Clayton

April 2, 2024 at 2:53 pm

Thank you for solving this, Dan!

We use anonymous cookies to give you the best experience we can.