There's been many times where I needed a matching rectangle behind a text layer, or even just need to know a shape layer's size and center. I got tired of remember the exact usage of the sourceRectAtTime() expression, especially getting the time right. So I made this preset.
Apply conigs_Measurements.ffx to a text or shape layer, and it will give you the Size (width, height), Center (x, y), Top-Left, and Bottom-Right coordinates, with the option for padding. It can get the measurements at the current time, or sample from a set time (maybe for an animated text layer where you want the box to stay static). It also has switches to take into account the scaling of the layer and to give you coordinates in composition space instead of relative to the layer.
Please note this requires AE 13.2 (CC2014) or later as the sourceRectAtTime() expression was first introduced in that version.
What you do with these numbers is up to you, but hopefully this will make it a little easier to rig up elements to another layer's size.
Measurements is part of the Conigs Mixtape preset pack.
Download Conigs Mixtape today!