Jump to content
Sign in to follow this  
Encity

AE expression to keep layer at a certain distance

Recommended Posts

i have a solid layer that i want to keep roughly 20px to the left of a line of text.

Thing is, i have many lines of texts to do at varying lengths (centered aligned) for multiple videos with different information.

 

So far i have been doing it manually after failing to find an expression solution.

 

Any tips? I imagine i need to find the text layers left most side in the world (or comp?) space and just grab that value and add -20px to the solid's layer X value. But im not the most proficient in expression, and my solutions have been futile.

 

Thanks in advance for any insight

Edited by Encity

Share this post


Link to post
Share on other sites

You are right. the quick and dirty way to do exactly what you're talking about is to put your solid layer right below your text and past the following into the position expression.

 

x = thisComp.layer(index-1).position[0]-20;

y = thisComp.layer(index-1).position[1];

 

[x,y]

 

With that expression your solid will snap to exactly 20 px to the left of the layer aboved it, so if you're doing it alot you just dup and move below another layer. you'd then fine tune position via your solid's anchor point as needed.

 

you could also swap the "-20" w "value[0]" and then the value of the x position of that layer will be added to the xpos of the layer above. in case you want to offset more.

Share this post


Link to post
Share on other sites

Hey foughtthelaw, i did something similar already, grabbing the layers position value and offsetting it 20.

 

The issue with this is that its taking the text layers position value, which is not what I want. (The expression ends up offsetting the solid 20px from the text layers anchorpoint)

 

This would be fine if my text was left aligned, but my text needs to be centered align.

 

So what i need to find is the text layers left most "position" value. (OR possibly the first character in the sentence's position value)

Share this post


Link to post
Share on other sites

There is no layerSize parameter on a text layer, only numnberOfCharacter.

If your font has a fix letter width, you can do some math like position - ((numberOfCharacter*characterWidth)/ 2).

Share this post


Link to post
Share on other sites

ah layersize parameter, thats what i was trying to remember.

Thanks for informing me that a text layer does not have that parameter. sad.

 

Let me tinker with the the character width.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...