ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Source text generated via expression not displaying correctly

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Paul Connors
Source text generated via expression not displaying correctly
on Apr 25, 2019 at 3:08:14 pm

Hi Guys. I'm rotating a text layer around a circle. It is parented to a null in the center and the null is rotating. I've added a bit to my expression to know the global position of the text layer. I'm trying to write the below expression in the Source Text so the layout of the text remains the same regardless of what side of the circle it falls on. I'd like to keep the "Name" closest to the circle regardless of what side of the circle it is on as in IMAGE 1 below. I've been able to get the text to auto-orient despite the 360 degrees of rotation the text is always facing the correct direction both horizontally and vertically but I can't figure out how to keep the "Name" field closest to the circle (IMAGE 2). My issue is with the source text expression. I wrote a conditional if/else statement that basically says: If the global position of the text is greater than 960 then do "Name - Date", else if the text is less than 960 then do "Date - Name". Here is what I have so far:

txt1 = thisComp.layer("Name").text.sourceText + " - " + thisComp.layer("Date").text.sourceText;
txt2 = thisComp.layer("Date").text.sourceText + " - " + thisComp.layer("Name").text.sourceText;
s = thisLayer;
globalPos = s.toComp(s.anchorPoint)[0];
if (globalPos > 960) txt1 else txt2


It actually seems to work ok in that I can see the layer bounding box expands to the length of those concatenated source text values, but it simply doesn't display correctly. It's only showing the default value of the text as if there wasn't an expression on that source text.

I should also mention that I have expressions on the scale (which I use to maintain the proper orientation of the text) and on the anchor point (which I use to maintain the proper distance from the circle). When I turn the anchor point expression off that text displays as it should according to the expression above. However, when the anchor point expression is turned on the text does not display correctly, but rather returns the default value as described above.

Here are some images to help show what I'm talking about:

IMAGE 1


IMAGE 2


IMAGE 3


Any help would be greatly appreciated. Thank you!


Return to posts index

Dan Ebberts
Re: Source text generated via expression not displaying correctly
on Apr 25, 2019 at 3:29:26 pm

If you're getting the default text, it might be because the expression is generating an error. If you're running a recent version of AE, that might be because of the last line (single-line if/else). Try replacing it with this:

globalPos > 960 ? txt1 : txt2


Dan



Return to posts index

Paul Connors
Re: Source text generated via expression not displaying correctly
on Apr 25, 2019 at 5:19:17 pm

Hi Dan. Thanks very much for your response. I'm running AE 15.1.2. Unfortunately I'm having the same issue with your update. Based on the size of the bounding box it looks like the underlying text generated from the expression is working, but it's still displaying the base value of the text layer. Interestingly, again, when I turn off the expression on the anchor point the text generated by the expression on the source text is correctly displayed, but now the orientation/position of the text is incorrect.


Return to posts index


Kalleheikki Kannisto
Re: Source text generated via expression not displaying correctly
on Apr 26, 2019 at 7:15:58 am
Last Edited By Kalleheikki Kannisto on Apr 26, 2019 at 7:16:45 am

I would try outputting the calculated global position value to the text layer itself to see if it is actually changing. I suspect you're somehow ending up with the layer's own anchor point position rather than the parented global position with your expression in the layer itself, although it seems correct when applied to a separate info text layer.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Paul Connors
Re: Source text generated via expression not displaying correctly
on Apr 29, 2019 at 2:10:49 pm

Hi Kalleheikki. That is a great suggestion. I just went ahead and tried that and the parented global position is in fact being calculated and used. I think it's some strange anomaly with the stacking of the expressions. I actually just made two layers for each bit of text. One that is only visible when the global position is greater than 960 and the other that is only visible when the global position is less than 960. While my timeline is much more complicated now it seemed to get the trick done. Thank you for your response!


Return to posts index

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