Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions sourceRectAtTime driving X position

  • sourceRectAtTime driving X position

    Posted by Thomas Collier on May 31, 2020 at 9:56 pm

    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.

    Thomas Collier replied 5 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 31, 2020 at 10:37 pm

    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

    Dan

  • Thomas Collier

    June 1, 2020 at 12:21 am

    Dan,

    Thank you so much, it worked beautifully. This shows my 3 “logos” (the thicker bars) and the 3 “rulers” the thinner bars. I am able to swap them with master properties as I please.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy