Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Marker comment to text in one line

  • Marker comment to text in one line

    Posted by Otávio Nascimento on September 8, 2022 at 7:59 pm

    Hey, I have a expression that copy comments from markers and add to text.
    But I want all the texts in one line. How do I do it?

     

     

    n = 0;

    t = 0;

    x = text.sourceText;

    if (marker.numKeys > 0){n = marker.nearestKey(time).index;

    if (marker.key(n).time > time) n–;}

    if (n > 0)

    marker.key(n).comment; else ”;

     

     

     

    I tried adding: replace(/\r/g, ”) at end of expression but didn’t work.

    Dan Ebberts replied 3 years, 8 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    September 8, 2022 at 8:29 pm

    I’m not sure what you’re asking exactly, but maybe like this:

    txt = "";
    if (marker.numKeys > 0){
    for (i = 1; i <= marker.numKeys; i++){
    txt += marker.key(i).comment;
    }
    }
    txt
  • Otávio Nascimento

    September 8, 2022 at 9:24 pm

    I want to remove from all comments the “enter to another line” so the text stays in one single line. So I can adjust the lines with the paragraph text.

  • Dan Ebberts

    September 8, 2022 at 9:46 pm

    That’s interesting. Apparently, carriage returns in marker comments have both carriage return and line feed characters. Try this:

    txt = "";
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (time < marker.key(n).time) n--;
    if (n > 0){
    txt = marker.key(n).comment.replace(/\r/g, "").replace(/\n/g, " ");
    }
    }
    txt
  • Otávio Nascimento

    September 8, 2022 at 10:29 pm

    Thank you! It worked, but if I want to edit one comment and add another line. Is it possible?

  • Dan Ebberts

    September 9, 2022 at 5:38 am

    I think so. It seems to work for me (but I may not understand what you’re asking).

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