ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Use SourceRectAtTime with multiple sources?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
David Cabestany
Use SourceRectAtTime with multiple sources?
on Oct 25, 2017 at 5:06:12 pm

Can I resize a rectangular shape layer using a bunch of text layers as the source so each time the text layer changes the box adjusts its size?

Text layer 1 happens from 0 to 1 seconds, text layer 2 from 2 to 3, etc.

I was thinking that it could perhaps be accomplished using markers or sampleImage() but not sure on exactly how.
Any ideas?


Return to posts index

Dan Ebberts
Re: Use SourceRectAtTime with multiple sources?
on Oct 25, 2017 at 5:41:16 pm

If I understand, there are a number of ways you could do it. If you know the times it could be like this:


if (time < 1)
sourceLayer = thisComp.layer("Text 1")
else if (time < 2)
sourceLayer = thisComp.layer("Text 2")
.
. // etc.
.
else
sourceLayer = thisComp.layer("Text n");

sourceLayer.sourceRectAtTime(time,false).width // etc


You could also do it with markers. Does that help?


Dan



Return to posts index

David Cabestany
Re: Use SourceRectAtTime with multiple sources?
on Oct 25, 2017 at 7:33:51 pm

Thanks Dan.
It almost works, when it reaches the last second, which is 18, the expression breaks, so I changed the last statement to:

if (time < 18
||
time>18.01
)

With that it runs ok so that's not an issue, however is not really following the edges of the layers, see attached:



I even added a few hundred pixels for x and y but still the box does not reach the edges of all text layers.

Any ideas why that could be? It only happens on some layers, and they all have the same specs as they are duplicates of each other, the only thing that changes is the length.

Thanks
D.

if (time &lt; 1
)
sourceLayer = thisComp.layer("servicios")
else
if (time &lt; 2)
sourceLayer = thisComp.layer("servicios 17")
else
if (time &lt; 3)
sourceLayer = thisComp.layer("servicios 15")
else
if (time &lt; 4)
sourceLayer = thisComp.layer("servicios 14")
else
if (time &lt; 5)
sourceLayer = thisComp.layer("servicios 13")
else
if (time &lt; 6)
sourceLayer = thisComp.layer("servicios 12")
else
if (time &lt; 7)
sourceLayer = thisComp.layer("servicios 11")
else
if (time &lt; 8)
sourceLayer = thisComp.layer("servicios 10")
else
if (time &lt; 9)
sourceLayer = thisComp.layer("servicios 9")
else
if (time &lt; 10)
sourceLayer = thisComp.layer("servicios 8")
else
if (time &lt; 11)
sourceLayer = thisComp.layer("servicios 7")
else
if (time &lt; 12)
sourceLayer = thisComp.layer("servicios 6")
else
if (time &lt; 13)
sourceLayer = thisComp.layer("servicios 5")
else
if (time &lt; 14)
sourceLayer = thisComp.layer("servicios 4")
else
if (time &lt; 15)
sourceLayer = thisComp.layer("servicios 3")
else
if (time &lt; 16)
sourceLayer = thisComp.layer("servicios 2")
else
if (time &lt; 17)
sourceLayer = thisComp.layer("servicios 16")
else
if (time &lt; 18
||
time>18.01
)
sourceLayer = thisComp.layer("servicios 18")


x=sourceLayer.sourceRectAtTime(time,false).width+150;
y=sourceLayer.sourceRectAtTime(time,true).height+20;
[x,y];


Return to posts index


Dan Ebberts
Re: Use SourceRectAtTime with multiple sources?
on Oct 25, 2017 at 7:55:05 pm

Hard to say without seeing it. Are you sure the display order of the layers matches the expression?

Dan



Return to posts index

David Cabestany
Re: Use SourceRectAtTime with multiple sources?
on Oct 25, 2017 at 8:04:20 pm

Yes, double checked it right after I noticed the discrepancy.
D.


Return to posts index

Dan Ebberts
Re: Use SourceRectAtTime with multiple sources?
on Oct 25, 2017 at 8:20:03 pm

Is there any scaling going in with any of the layers?

BTW-I think that last test could just be:

else
sourceLayer = thisComp.layer("servicios 18");

Dan



Return to posts index


David Cabestany
Re: Use SourceRectAtTime with multiple sources?
on Oct 25, 2017 at 8:31:22 pm

I changed the layer names to index numbers and the discrepancy in size remained. Very strange.
My guess is this expression is still buggy and is not reading each frame the way it's supposed to. I'm going to report it to Adobe.


Return to posts index

Dan Ebberts
Re: Use SourceRectAtTime with multiple sources?
on Oct 25, 2017 at 8:38:14 pm

I don't know if it applies here, but if your text layers have been scaled, that won't be reflected in the sourceRect results.

Dan



Return to posts index

David Cabestany
Re: Use SourceRectAtTime with multiple sources?
on Oct 25, 2017 at 9:01:54 pm

No, all layers are at 100% and there is no parenting whatsoever.
I ended up scaling down the shape layer, now it works, but only when the layer is at 68.2% of its original size (1920x1080).

Anyway, the bulk of the expression works and that's what matters. Thanks a lot for your help Dan.


Return to posts index

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