Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Getting name for previous composition

  • Getting name for previous composition

    Posted by Kirill Komrakov on July 9, 2024 at 8:29 am

    Hi, I am trying to create an expression, where I am aligning one composition under another but with dynamically figuring out the name for the one, under which another is aligned. The general idea is to create a bullet list but without a need to constantly rewrite expression to fit compositions names.


    <font face=”inherit”>With the help of chatGPT </font>I’ve<font face=”inherit”> </font>managed<font face=”inherit”> to get this far, but </font>I<font face=”inherit”> am getting and </font>error<font face=”inherit”> “T01 Text aN does not exist” and </font>I<font face=”inherit”> can’t figure out, why AE don’t calculate right name. Would </font>appreciate some help. Thanks!

    // Get the current composition name

    var currentCompName = thisComp.name;

    // Extract the composition number

    var compNumber = parseInt(currentCompName.split(” “)[2]);

    // Calculate the previous composition number

    var prevCompNumber = compNumber – 1;

    // Format the previous composition name

    var prevCompName = “T01 Text ” + (“0” + prevCompNumber).slice(-2);

    // Get the text layers from the compositions

    var textLayer1 = comp(prevCompName).layer(1);

    var textLayer2 = thisComp.layer(1);

    // Get the position of the first text layer in the previous composition

    var aX = textLayer1.transform.position[0];

    var aY = textLayer1.transform.position[1];

    // Get the heights of both text layers

    var aH = textLayer1.sourceRectAtTime(time).height;

    var bH = textLayer2.sourceRectAtTime(time).height;

    // Get the spacing adjustment

    var adjustments = comp(“T01 Color & Adjustments”).layer(“Color & Adjustments”);

    var SpS = adjustments.effect(“Text Lines Spacing”)(“Slider”).value;

    // Calculate final x and y positions

    var x = aX;

    var y = aY + aH / 2 + SpS + bH / 2;

    [x, y];

    That is with assuming that all the compositions are named sequentially T01 Text 01, 02, 03

    Kirill Komrakov replied 2 years ago 1 Member · 1 Reply
  • 1 Reply
  • Kirill Komrakov

    July 10, 2024 at 6:48 am

    Ah, figured it out, the mistake was at first line to use thisComp. The right way would be thisLayer

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