Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions $evalfile, Stylizing external text on the same line.

  • $evalfile, Stylizing external text on the same line.

    Posted by Brian Nishii on July 18, 2014 at 9:21 am

    I am creating Lower 3rds by pulling text from an external file and am successfully pulling four variables via:

    myPath = “/Volumes/PFH2014_01/_WW MASTER/01 PROJECTS/02 AE/L3source.txt” ;
    $.evalFile(myPath);
    try{
    eval(thisComp.name) [0] ;
    }catch (err){
    “Missing”;
    }

    I would like to style two variables on a single “line” of text but position the text dynamically like so:

    (var0) FirstName LastName (var1) Title of this person
    (var2)SomeOtherPertinentInfo (var3) SomeMoreInfo

    or

    (var0)AReallyReallyImpossiblyLongNameForExample (var1) Title of this
    (var3)InfoHereBecauseVAR2isEmpty

    Can anybody point me in the right direction of how to do this?
    I know you could do this on the same line if they were stylized the same because you could just print it in the expression field of the text layer with the two variables, but different styling would require different text layers, no?

    I have to delve into scripting to get exact text width of var0 in order to position var1 a certain amount of pixels to the right of it…….or could I position both var1 and var2 at the same location, pull the text length in integer numbers from var 1, and then somehow add that number of spaces before I print var2?

    Any help would be appreciated.

    Thanks!

    Brian Nishii replied 11 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    July 18, 2014 at 5:17 pm

    When a text layer’s text is updated by an expression or script, everything gets the formatting of the first character. To have different styling, you’d have to use separate text layers. Positioning the layers based on the dimensions of the actual text is straight forward with scripting, problematic with expressions.

    Dan

  • Brian Nishii

    July 18, 2014 at 9:53 pm

    Thank you Dan for your response.

    I tried using your script posted elsewhere to retrieve text layer coordinates by the sampleImage method, but kept on getting time-out errors so I gave up.

    In the end, I figured out a not so precise but perfectly acceptable solution: because the text layer styling is constant, I pulled the character index of the first text layer, multiplied it by an appropriate number of pixels, to get an X position offset for the second layer.

    In case any non-smart amateur out there like me is curious, here’s what I did for dynamically spacing variables for my Lower Thirds off of a text file, and my workflow:

    1) Create a text file, with a line for each LowerThird:

    var L3_1 = [“Variable0text”, “Variable1text”, “Variable2text”,”Variable3text”];

    2) In AE, design Lower Third comp. In my case, I wanted two “text lines” with 2 variables each being pulled in to look like:

    Variable0 Variable1
    Variable2 Variable3

    3) For the position value of Variable1:

    pos=thisComp.layer("Variable0TextLayer").transform.position;
    st=thisComp.layer("Variable0TextLayer").text.sourceText;
    ix=st.length;
    X=pos[0]+(ix*22);
    Y=pos[1];
    Z=pos[2];
    [X,Y,Z]

    So in my case, 22 pixels was the right amount of offset per character of Variable 0 to give an offset for Variable1.

    4) For the Source text field of each Variable:


    myPath = "/Volumes/myPath/L3source.txt" ;
    $.evalFile(myPath);
    try{
    eval(thisComp.name) [1];
    }catch (err){
    "Missing";
    }

    5) Once design is set, Duplicate L3_1 the number of times you have LowerThirds, and move renders into a designated folder. Any time you need to make design changes, change L3_1, duplicate, batch render, replace into said folder, and NLE relinks…..

    Awesome workflow for a wishy washy client. GOLDEN!!

    If it weren’t for geniuses like Dan Ebberts, what would us dumb folk do?

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