Forums › Adobe After Effects Expressions › Layer Position Relative to Text Length
-
Layer Position Relative to Text Length
-
Andrew Musselman
June 7, 2018 at 9:16 pmI know this is an old thread, and I’m not that great with expressions. This should do exactly what I need it to, but how do I use it? Where on which layer does this get pasted?
Thanks for the help!
L = thisComp.layer("text");
rect = L.sourceRectAtTime(time,false);
x = L.toComp([rect.left+rect.width,0])[0];So something like this would position a layer 10 pixels to the right of the text:
gap = 10;
L = thisComp.layer("text");
rect = L.sourceRectAtTime(time,false);
x = L.toComp([rect.left+rect.width,0])[0];
[x+gap+width/2,value[1]]Never Stop Learning.
-
Dan Ebberts
June 7, 2018 at 10:52 pmThat would be a Position expression for a layer that you want to line up to the right of the text layer.
Dan
-
Andrew Musselman
June 8, 2018 at 2:49 amAwesome!!! And what if I wanted to use it for text on the left side of the layer?
Never Stop Learning.
-
Kalleheikki Kannisto
June 10, 2018 at 6:33 amAlthough I didn’t read that very carefully, I expect it should work by changing the last line to
[x-gap-width/2,value[1]]
Kalleheikki Kannisto
Senior Graphic Designer -
Nikola Morin
November 23, 2020 at 4:27 pmI Guys!
I Wrote This Expression like Dan Suggest:gap = 10;
L = thisComp.layer(“text”).text.sourceText;
rect = L.sourceRectAtTime(time,false);
x = L.toComp([rect.left,0])[0];
[x-gap-width/2,value[1]]
and the answer of After effect is L.sourceRectAtTime is not a function….
don’t know what to do….
I Using After Effect CC 2020 V.17.5.1Thank in Advance
-
Dan Ebberts
November 23, 2020 at 4:47 pmTry changing the 2nd line to:
L = thisComp.layer("text");
-
Nikola Morin
November 23, 2020 at 4:54 pmThank you very much, that’s Working!
What will be the wordl without a Dan Ebbert?? -
Tanja Burgin
May 27, 2022 at 9:17 pmHi there
I have a similar problem and unfortunately I can’t find a solution on the internet. Maybe someone can help me here?
I have a background area (white) whose size adjusts to the text-layer. Now I want to add a colored bar in front of the background area. The position of the bar must adapt to the size of the background area. Unfortunately I can’t find a solution for this. How could I do that?
Thanks a lot
TanjaIt should look like this (video) but with a colored bar in front of the white background (like the second row). There is also the Code I used (photo):
– Formebene 1 = White Background
– Name = Layer with Text
Log in to reply.