Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions how to get ‘actual’ width of a text layer.

  • how to get ‘actual’ width of a text layer.

    Posted by Jamie Bradshaw on February 10, 2008 at 9:01 pm

    Is there an expression that returns the actual width of a text layer?

    For example, if you have a text layer, it’l return the actual width of the text, and not the composition width.

    I’ve tried:

    n = thisLayer.width;

    but that doesn’t work.

    Many thanks,
    Jamie

    Jan Vork replied 8 years, 10 months ago 4 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    February 10, 2008 at 9:19 pm

    You can do it with scripting, but not expressions.

    Dan

  • Jamie Bradshaw

    February 11, 2008 at 10:18 am

    Ah okay, thanks Dan.

    I haven’t had much dealing much with scripting. Would this be a difficult thing to do?

  • Dan Ebberts

    February 11, 2008 at 1:20 pm

    Not really. Here’s a simple snippet that assumes your text layer is layer 1:

    var myLayer = app.project.activeItem.layer(1);
    var r = myLayer.sourceRectAtTime(0, false);
    alert(r.top + ” ” + r.left + ” ” + r.width + ” ” + r.height);

    The top and left values are relative to the layer’s anchor point.

    Dan

  • Lloyd Alvarez

    February 11, 2008 at 2:49 pm

    Actually NAB figured out a way to get the size of a text layer in expressions using sampleImage. He posted his expression over at ae nhacers. I don’t think the cow allows posting any ae nhancers urls so just replace [dot] with a .

    www[dot]aenhancers[dot]com/viewtopic.php?f=6&t=931

  • Jamie Bradshaw

    February 11, 2008 at 2:55 pm

    Thanks Lloyd, I’ll go and check that out. I think picking up the whole concept of scripting might be a little too much for me at this moment in time.

    Jamie

  • Dan Ebberts

    February 11, 2008 at 2:55 pm

    Yeah, I just saw that. It should work fine. A bit slow maybe, but way better than not being able to do it at all.

    Dan

  • Jan Vork

    July 3, 2017 at 11:03 am

    Try this:


    x=thisComp.layer(“nameofthelayer”).sourceRectAtTime().width;

    x=thisComp.layer("nameofthelayer").sourceRectAtTime().width;

    http://www.jaydude.nl

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