ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Measuring width of objects in precomp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Yan Trudel
Measuring width of objects in precomp
on Jun 19, 2017 at 3:57:49 pm

Hi everyone,

I dont post here often since a lot of times I find my answers on the forums from other people facing the same challenges. Thank all of you guys for all the knowledge you guys share everyday.

I'm working on a project where I'm building a template for editors to use to put in the day and time at which shows play.
That info then appears in 2 boxes that are side to side. Depending on the input text, the width of the combined boxes is always different.

Here is what it looks like :

My question : can After effects calculate the total width if they are inside a precomp and how could i go about doing that?

Thanks in advance!


Return to posts index

Dan Ebberts
Re: Measuring width of objects in precomp
on Jun 19, 2017 at 5:26:24 pm

Hard to say exactly without knowing more detail, but probably something like this:

r = comp("your precomp name").layer("your layer name").sourceRectAtTime(time,false);
r.width


sourceRectAtTime() is the key.

Dan



Return to posts index

Yan Trudel
Re: Measuring width of objects in precomp
on Jun 19, 2017 at 5:41:48 pm

Thanks for the quick response Dan! By the way, you've been answering so many expressions questions I have had over the year so thanks for that too!

I had actually tried sourceRectAtTime() but since the result of those 2 boxes is precomposed, it gives me the width of that composition.

In my current build I use sourceRectAtTime() for each of the boxes with the text; one is right aligned and the other left aligned. They are in different compositions that are then juxtaposed. I'm actually trying to figure out the total length so I can always center the result of the combined width of the boxes since it can vary a lot :

Although maybe my approach might be where I'm going wrong here?


Return to posts index


Dan Ebberts
Re: Measuring width of objects in precomp
on Jun 19, 2017 at 5:47:11 pm

I was assuming that you would use comp() to target the precomp so that you would have access to the layers inside.

Dan



Return to posts index

Yan Trudel
Re: Measuring width of objects in precomp
on Jun 19, 2017 at 5:52:23 pm

Oh, rookie mistake!
I'm going to try it out now!


Return to posts index

Yan Trudel
Re: Measuring width of objects in precomp
on Jun 19, 2017 at 6:07:28 pm

Thanks Dan!

Since I'm not the expert, I sometimes forget I can reference directly into comps... Seems like it was rather simple but greatly appreciate the help! ☺

I've used the expression you gave me to measure the total width like this :

j = comp("Precomp_JOUR").layer("boite_jour").sourceRectAtTime(time,false);
h = comp("Precomp_HEURE").layer("boite_heure").sourceRectAtTime(time,false);

h.width+j.width;


Now going to work on getting it to center automatically. Thanks again!


Return to posts index

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