Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expression for text following text in height

  • Expression for text following text in height

    Posted by Kieran Johnson on October 29, 2021 at 5:16 pm

    Hi , I am new to expression and building a 4 line text graphic .

     

    Message 1

    Show Line 1

    Show Line 2

    Tx 1

     

    I have show line 1 and 2 currently attached to a null with a scaling expression in the null that resizes the size of text depending on how many character are put in and calcualting its width in the safe area. (script below)

     

    My issue is i want to have tx 1 and message 1 follow Show line 1 and show line 2, but without scaling . How can i get these layers to follow show line 1 and 2?

     

    //this expression is applied to the Scale Property of a NULL object controlling multiple text layers

    var title_safe = 1250; //width of the title safe area in pixels

    var width_array =[] // create an array to hold the widths of all text layers

    width_array.push(thisComp.layer(“Show 1 Title Line 1”).sourceRectAtTime().width); //add the width of each text layer to the array

    var width_array =[] // create an array to hold the widths of all text layers

    width_array.push(thisComp.layer(“Show 1 Title Line 2”).sourceRectAtTime().width); //add the width of each text layer to the array

    // … add as many layers as required

    var max_width = Math.max.apply(this,width_array); // find the longest the line of text

    var maxsize = Math.min(title_safe/max_width*100,100) //calculate a scaling factor based on the longest line and title safe width

    var result = [maxsize,maxsize]; //write result array of scaling factors of x and y

    thisProperty = result; // this line sets the scale [x,y] with the result array

    Graham Quince replied 4 years, 6 months ago 3 Members · 2 Replies
  • 2 Replies
  • Meng Zhiqun

    October 30, 2021 at 5:11 am

    Hey Kieran,

    When you said you want it to follow but not scale, do u mean position? If that’s the case, does linking up their position help?

  • Graham Quince

    October 30, 2021 at 10:01 am

    If I’m following correctly, you’d like the Message and Show Line 1 to be larger than the rest of the text layer, unfortunately text expressions in After Effects cannot set to be different sizes.

    But, if you make this a pre-comp, then use Essential Graphics, you could have the top two lines on one text layer and the rest on another. Bringing this pre-comp into your main comp, you’ll be able to update the text values.

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