Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Super weird expression oddity

  • Super weird expression oddity

    Posted by Nick Hill on March 3, 2023 at 4:55 pm

    I’m creating a mogrt which is essentially a jazzed up box with some text on it. Somehow this behemoth now has over 40 controls on it for things like where the box is, how long the text stays on screen etc. One of the controls gives the size of the main text body (which can have up to 8 lines), and I just need it to give the maximum size of that block; I can’t use sourceRectAtTime() because each line can have a different size, so it’s only clear how big the whole thing is once all the different sizes are taken into account.

    Thing is, that applying this expression to the control freaks the entire thing out. You can see what’s happening here:

    It’s not that the expression is returning a different pair of values than are currently hard-coded into the point control – I’ve set them to be the same, for this text layout. It’s just that for some reason, applying this expression causes everything to go weird. I’ve rewritten it a couple of times, and checked there’s no accidental recursion or anything. Deleted cache, restarted AE etc etc. I can’t work it out – any ideas?
    The code is:

    n = effect("numLines")("Slider"); // gives how many actual lines of text there are
    minx = miny = 10000;
    maxx = maxy = 0;
    tl = br = [];
    for (i = 1; i <= n; i++) {
    L = thisComp.layer("Line " + i); // text lines are called Line 1, Line 2, etc.
    // each text layer has a top left / bottom right
    // point control worked out with sourceRectAtTime(time, true)
    tl = L.effect("tl")("Point");
    br = L.effect("br")("Point");
    if (tl[0] < minx) minx = tl[0];
    if (tl[1] < miny) miny = tl[1];
    if (br[0] > maxx) maxx = br[0];
    if (br[1] > maxy) maxy = br[1];
    [maxx-minx, maxy-miny]

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Vimeo framework” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

    Nick Hill replied 11 months, 2 weeks ago 2 Members · 2 Replies
  • 2 Replies
  • Yoan Boisjoli

    March 8, 2023 at 3:28 pm

    Hey Nick, I’m not sure whats going on here. But if you create lots of mogrt and worry about position, this is the best investment I made in awhile:

    You should check it out. It might solve your problem.

  • Nick Hill

    March 8, 2023 at 3:52 pm

    Thanks Yoan, I’ll check that out.

    I eventually solved this by calculating the height of each line of text with its .leading property, rather than using sourceRectAtTime. Still can’t work out why sourceRect was throwing everything off.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy