ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

sourceRectAtTime driving X position

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Thomas Collier
sourceRectAtTime driving X position
on May 31, 2020 at 9:56:59 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.


Return to posts index

Dan Ebberts
Re: sourceRectAtTime driving X position
on May 31, 2020 at 10:37:52 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



Return to posts index

Thomas Collier
Re: sourceRectAtTime driving X position
on Jun 1, 2020 at 12:21:13 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.



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]