Skip to main content
Gotta Dance
Inspiring
July 12, 2023
Answered

MOGRT Value as Expression Value?

  • July 12, 2023
  • 3 replies
  • 980 views

Hi Everybody,

 

I have a situation where I'm MOGRTing a lower third and the two text boxes in the lower third, on exit, animate to the right sliding out of the mask set. Easy enough - animate in, animate out of the mask.

 

BUT...the problem I have is that since these boxes/type can change width (due to name length) I have to determine how far they slide out on the exit. In the MOGRT, I can enter the type and the mask/box width, but I can't determine that final keyframe (xPos) where the length of type/box is supposed to slide to without expressions. 

 

So before even getting to any ease expressions, I need to pass a value from the MOGRT field to the layer to tell it, "Hey this is the x position you need to slide to with the name text to exit the mask".

 

Is that even possible with MOGRT, or do I need to enter it via an Excel sheet or something? 

 

This topic has been closed for replies.
Correct answer Rick Gerard

If you use shape layers as track mattes instead of masks, you can easily calculate the width of the layer by adding the left value to sourceRectAtTime().width. Without understanding how you are changing the size of the Mask. Personally I would drive the entire animation with expressions. There would be no keyframes. I would use time minus in-point and time minus out point minus the animation duration and a linear or ease interpolation to setup the animation. Combine that with sourceRectAtTime to calculate the size of the text layer plus any necessary padding and some simple math for position and you have the whole thing. If you added some sliders you could change the timing of the in and out animation, and the animation would always start and end at the end of a frame. Combine a starting and ending protected area in the timeline and you have an animated lower third animation that can have any duration you like and that animated in and out perfectly.

 

I'll demonstrate how to move a text layer in from the left so that the first letter is positioned to the right of the left edge of the composition by a specific percentage of the comp width, then slides out to the right until. Applying this expression to any text layer will get it to animate based on the layer's in and out points. The comments in the expression preceeded by double backslashes show you what values to change to position the text layer where you want it to be and control the timing of the animation. I hope this helps:

siz = sourceRectAtTime();
w = siz.width - siz.left;
h = siz.height - siz.top;
rest = thisComp.width * .08;//percentage of the comp width for resting position
hP = thisComp.height * .9;//percentage of the comp height for the text
mIn = 20;//Number of frames it takes to move the text in
mOut = 40;//Number of frames it takes to move outPoint
p1 = w - siz.width   * 2;
p2 = p1 + siz.width + rest;
p3 = thisComp.width - siz.width + w;
t = (time - inPoint) / thisComp.frameDuration;
endT = (outPoint) / thisComp.frameDuration;
if (t < mIn + 1){
	x = easeIn(t, 0, mIn, p1, p2);
}
else{
	x = easeOut(t, endT - mOut, endT, p2, p3)
}
y = h - siz.height + hP - siz.height;
[x, y]

No matter what the paragraph justification or the baseline shift this expression will move a text layer from offscreen on the right side of a comp  to 8% of the comp width in 20 frames, then move it offscreen to the left over the last 40 frames of the layer while the bottom of the text layer stays at 75% of the comp height. You could replace the percentages (.08 and .90) and the number of frames (20 and 40) with expression control sliders to have a fully customizable MOGRT thata would let you customize the position and the speed of the animation. 

 

Tie the second text layer, and if needed, the Background Graphic to the position of the main text layer and you should have it.

 

The expression could be simpler if you did not compensate for paragraph justification or baseilne shift. I ahve about 40 animation presets for Text layers that I have written that do all kinds of moves with and without backgrounds. 

 

One day soon I will publish a tutorial series that should help anyone interested in automating animatiion to create their own presets to speed up their work and differentiate it from stock motiion graphics templates that so many are using. 

 

 

 

3 replies

Mathias Moehl
Community Expert
Community Expert
July 13, 2023

That's exactly what the Position Controls of Pins & Boxes are made for:

 

Learn more about Pins & Boxes here:

https://aescripts.com/pins-and-boxes/

 

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Gotta Dance
Inspiring
July 13, 2023

Hi Mathias, this Pins and Boxes looks awesome. I'll have to check this out later today after work. I'm not sure if I can use it in this instance though as I'm sharing with others through a MOGRT and I don't believe my other video editor counterparts have the same plugin (which they would need, right?). Thanks a bunch fro posting this though, it looks really helpful, intruiging for sure. 

Mathias Moehl
Community Expert
Community Expert
July 13, 2023

Your colleagues don't need the plugin. Pins & Boxes creates expressions rigs and these continue to work also on machines, where Pins & Boxes is not installed. So your colleagues can use both the Ae project and Mogrts created from it without the need to install Pins & Boxes. You can also use it to create and sell templates, for example.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Rick GerardCommunity ExpertCorrect answer
Community Expert
July 12, 2023

If you use shape layers as track mattes instead of masks, you can easily calculate the width of the layer by adding the left value to sourceRectAtTime().width. Without understanding how you are changing the size of the Mask. Personally I would drive the entire animation with expressions. There would be no keyframes. I would use time minus in-point and time minus out point minus the animation duration and a linear or ease interpolation to setup the animation. Combine that with sourceRectAtTime to calculate the size of the text layer plus any necessary padding and some simple math for position and you have the whole thing. If you added some sliders you could change the timing of the in and out animation, and the animation would always start and end at the end of a frame. Combine a starting and ending protected area in the timeline and you have an animated lower third animation that can have any duration you like and that animated in and out perfectly.

 

I'll demonstrate how to move a text layer in from the left so that the first letter is positioned to the right of the left edge of the composition by a specific percentage of the comp width, then slides out to the right until. Applying this expression to any text layer will get it to animate based on the layer's in and out points. The comments in the expression preceeded by double backslashes show you what values to change to position the text layer where you want it to be and control the timing of the animation. I hope this helps:

siz = sourceRectAtTime();
w = siz.width - siz.left;
h = siz.height - siz.top;
rest = thisComp.width * .08;//percentage of the comp width for resting position
hP = thisComp.height * .9;//percentage of the comp height for the text
mIn = 20;//Number of frames it takes to move the text in
mOut = 40;//Number of frames it takes to move outPoint
p1 = w - siz.width   * 2;
p2 = p1 + siz.width + rest;
p3 = thisComp.width - siz.width + w;
t = (time - inPoint) / thisComp.frameDuration;
endT = (outPoint) / thisComp.frameDuration;
if (t < mIn + 1){
	x = easeIn(t, 0, mIn, p1, p2);
}
else{
	x = easeOut(t, endT - mOut, endT, p2, p3)
}
y = h - siz.height + hP - siz.height;
[x, y]

No matter what the paragraph justification or the baseline shift this expression will move a text layer from offscreen on the right side of a comp  to 8% of the comp width in 20 frames, then move it offscreen to the left over the last 40 frames of the layer while the bottom of the text layer stays at 75% of the comp height. You could replace the percentages (.08 and .90) and the number of frames (20 and 40) with expression control sliders to have a fully customizable MOGRT thata would let you customize the position and the speed of the animation. 

 

Tie the second text layer, and if needed, the Background Graphic to the position of the main text layer and you should have it.

 

The expression could be simpler if you did not compensate for paragraph justification or baseilne shift. I ahve about 40 animation presets for Text layers that I have written that do all kinds of moves with and without backgrounds. 

 

One day soon I will publish a tutorial series that should help anyone interested in automating animatiion to create their own presets to speed up their work and differentiate it from stock motiion graphics templates that so many are using. 

 

 

 

Gotta Dance
Inspiring
July 13, 2023

"If you use shape layers as track mattes instead of masks, you can easily calculate the width of the layer by adding the left value to sourceRectAtTime().width" - Yes, very good. I was wondering how to arrive at calcluation width as my keyframes are using scale percentage which isn't really transferable data to pin a location. ?? Was really stuck there. Thanks for pointing that out. That helps clarify things. I'll use them as mattes and use the JS command, "sourceRectAtTime" as my access point for that value to tell the text how far to travel as the "final keyframe". Of course, yeah there's no way to access the keyframe with this information so I'll have to practice doing easing with expressions. This MOGRT scenario is sure roping me into expressions like somebody kicked the horse. LOL Thanks a bunch Rick, I very much looked forward to your tutorials. 🙂

Mylenium
Legend
July 12, 2023

You have to calculate it based on the text box. Shouldn't be too difficult to calculate an offset based on the position differences if you assume a certain default size as reference.

 

Mylenium