Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions position a shape to the end of a text

  • position a shape to the end of a text

    Posted by Gerg Tolcs on September 23, 2015 at 3:47 pm

    Hi, maybe it’s not a real problem, I just want to ask you, maybe you have more experiences with this issue.

    I’m working with text and shape layers, and don’t use anything, just script files. I want to position a shape to the end of a text, position the next text to the ‘end’ of the shape, etc

    The text is changing, and I have to count the positions again and again.

    I use the sourceRectAtTime function, to find the end of the text layer, and a constant, to position the shape to the right coordinate. It’s ok, but not perfect.

    I realized, that the values from sourceRectAtTime are not the best for me. I made a little script (post it here, and of course, there are some exceptions 🙂 🙂 ) to look how it works, an I find, that last and first characters affect the width more than the others. MAGE.width != AMGE.width, but MAGE.width == MGAE.width

    Did you have what can I do – a shorter/easier way – to find the right place for my shapes in the center between two text layers, what are changing? Thank you!

    var myComp = app.project.activeItem;
    var abc = 'ABCDEFGHIJKLMNOPQRSTUVZ';
    var myText = myComp.layers.addText('');
    var textSource = myText.property("Source Text");
    var output3 = '';
    var word, letter1, letter2, resultNUM;

    for(var i=0; i<3; i++){
    letter1 = abc .substr(Math.floor(Math.random()*22),1);
    letter2 = abc .substr(Math.floor(Math.random()*22),1);

    for (var j=0; j<7; j++){
    word = '';
    for (var k=0; k>>

    /*
    P///29.9994142726064
    T///25.8761719800532
    !word - word : 4.12324229255319
    -
    P///29.9994142726064
    T///25.8761719800532
    !word - word : 4.12324229255319
    -------

    PB///79.7273905519396
    TB///76.933347530663
    !word - word : 2.79404302127659
    -
    BP///80.8260233644396
    BT///74.845945186913
    !word - word : 5.98007817752659
    -------

    PAR///122.69540578872
    TAR///119.901362767443
    !word - word : 2.79404302127659
    -
    ARP///127.52939016372
    ART///120.414058079943
    !word - word : 7.11533208377659
    -------

    PACK///165.150729527697
    TACK///162.35668650642
    !word - word : 2.79404302127659
    -
    ACKP///171.387155361474
    ACKT///165.407077183947
    !word - word : 5.98007817752659
    -------

    PCBJB///208.33436610736
    TCBJB///205.540323086083
    !word - word : 2.79404302127659
    -
    CBJBP///207.397158971056
    CBJBT///201.41708079353
    !word - word : 5.98007817752659
    -------

    PVNIBQ///259.981576748192
    TVNIBQ///257.187533726916
    !word - word : 2.79404302127659
    -
    VNIBQP///261.838412633166
    VNIBQT///255.858334455639
    !word - word : 5.98007817752659
    -------

    PKJJCLP///282.672342129052
    TKJJCLP///279.878299107775
    !word - word : 2.79404302127659
    -
    KJJCLPP///282.818826504052
    KJJCLPT///276.838748326525
    !word - word : 5.98007817752659
    -------

    R///30.6585939601064
    M///29.9777344800532
    !word - word : 0.68085948005319
    -
    R///30.6585939601064
    M///29.9777344800532
    !word - word : 0.68085948005319
    -------

    RJ///59.9303201343864
    MJ///65.0830544568598
    !word - word : -5.15273432247341
    -
    JR///70.8800271656364
    JM///72.0044411756098
    !word - word : -1.12441400997341
    -------

    RNK///126.529780736193
    MNK///131.682515058666
    !word - word : -5.15273432247341
    -
    NKR///125.907222142443
    NKM///127.031636152416
    !word - word : -1.12441400997341
    -------

    RTLI///144.679538121447
    MTLI///150.96752635017
    !word - word : -6.28798822872341
    -
    TLIR///153.285495152697
    TLIM///154.40990916267
    !word - word : -1.12441400997341
    -------

    RJTLV///194.067080846056
    MJTLV///199.21981516853
    !word - word : -5.15273432247341
    -
    JTLVR///201.244815221056
    JTLVM///202.36922923103
    !word - word : -1.12441400997341
    -------

    RISBJR///237.056772060692
    MISBJR///242.209506383166
    !word - word : -5.15273432247341
    -
    ISBJRR///235.251498570666
    ISBJRM///236.375912580639
    !word - word : -1.12441400997341
    -------

    RQFGSPB///314.690002704039
    MQFGSPB///319.842737026513
    !word - word : -5.15273432247341
    -
    QFGSPBR///316.510217495263
    QFGSPBM///317.634631505236
    !word - word : -1.12441400997341
    -------

    K///28.3406251575798
    Q///36.0052736476064
    !word - word : -7.66464849002659
    -
    K///28.3406251575798
    Q///36.0052736476064
    !word - word : -7.66464849002659
    -------

    KI///58.5020974781364
    QI///65.8263162281364
    !word - word : -7.32421875
    -
    IK///61.2012185193598
    IQ///66.9981912281364
    !word - word : -5.79697270877659
    -------

    KJV///106.754390111193
    QJV///114.078608861193
    !word - word : -7.32421875
    -
    JVK///112.602925214916
    JVQ///118.399897923693
    !word - word : -5.79697270877659
    -------

    KIHM///163.576022496447
    QIHM///170.900241246447
    !word - word : -7.32421875
    -
    IHMK///166.27514353767
    IHMQ///172.072116246447
    !word - word : -5.79697270877659
    -------

    KJLSC///190.697940221056
    QJLSC///198.022158971056
    !word - word : -7.32421875
    -
    JLSCK///197.31551829353
    JLSCQ///203.112491002306
    !word - word : -5.79697270877659
    -------

    KUFPTU///259.567904820666
    QUFPTU///266.892123570666
    !word - word : -7.32421875
    -
    UFPTUK///262.230404768139
    UFPTUQ///268.027377476916
    !word - word : -5.79697270877659
    -------

    KOASMTI///293.428088536486
    QOASMTI///300.752307286486
    !word - word : -7.32421875
    -
    OASMTIK///299.726916661486
    OASMTIQ///305.523889370263
    !word - word : -5.79697270877659
    -------

    */

    Kalleheikki Kannisto replied 10 years, 7 months ago 2 Members · 6 Replies
  • 6 Replies
  • Gerg Tolcs

    September 23, 2015 at 3:49 pm

    “The text is changing” === Source Text is changing, not position, or anything else

  • Kalleheikki Kannisto

    September 23, 2015 at 4:06 pm

    Sounds very complex. If you can upload a picture or two of what you are trying to achieve, perhaps there is a whole different approach someone can suggest for the problem.

  • Gerg Tolcs

    September 24, 2015 at 8:17 am

    Maybe it will show my problem, thank you!

  • Kalleheikki Kannisto

    September 24, 2015 at 9:02 am

    It is not an After Effects solution, but I would make this into a font with those shapes as characters, then you could type it in as text and everything else would be pretty straightforward.

    I use Fontlab’s FontoGrapher but there are some free font creation programs that should do it as well:

    https://mashable.com/2011/11/17/free-font-creation-tools/#TAsnSvmcZGkP

  • Gerg Tolcs

    September 24, 2015 at 9:21 am

    Great idea, but I’m afraid, It doesn’t work for me, It’s a lyric video, and all the 240 words contain these two characters. The Idea, that the shape chracters stays on the screen, and the other parts of the words appear and disappear, with animation, 3d position, opacity, etc, anything, I guess, impossible make it with one textlayer/word :/

  • Kalleheikki Kannisto

    September 24, 2015 at 9:51 am

    I see. So you need the two shapes to smoothly move from one position to the next while the words around them change.

    How about creating the words with placehold characters with suitable spacing for the shapes such as bullet and asterisk with spaces on each side (” • ” and ” * “), then calculating the position of just those characters and animating the position of the shapes to match the positions of the bullet and the asterisk? You wouldn’t have to worry about spacing any of the characters in the words, just calculating those two locations in the consecutive words and animating the position of the shapes between them.

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