I have a precomp with about 10 logos in it of varying width. I am using a dropdown menu to drive opacity to show individual layers. That precomp is placed into a comp four times, showing 4 different logos using master properties. I would like to drive the x position of these layers based on the width of the layer to it's left, so they maintain an equal distance between logos no matter the width of the logo.
I am getting a bit lost at this point. I am under the impression sourceRectAtTime can calculate the width of the layer, plus some padding to position the next logo. However, my logo dropdown is producing an index result. I tried collapsing transformations, but the sourceRect doesn't change because in the precomp all the layers are still on, just opacity is changing. Is there a way to access the sourceRect of a layer through a dropdown? Or to truly turn off layers with expressions, instead of just opacity? Thank you for your help, sorry if this is a basic question.
It's hard to say without seeing your setup exactly, but you should be able to use the index provided by the dropdown to select the correct layer in the precomp and then use sourceRectAtTime() to get the width of that layer:
idx = thisComp.layer("Controls").effect("Logo")("Menu").value;
w = comp("precomp").layer(idx).sourceRectAtTime(time,false).width