Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions guess shape layer content width?

  • guess shape layer content width?

    Posted by Peter Zeet on May 7, 2016 at 3:05 pm

    hiya!
    I’m trying to automate some shape animations proccess following a slider’s values from a null called “control”.
    I have a bunch of layers, and on every layer a different letter, which is a shape layer. I masked the layer itself, but I’m moving the letter (so the content shape’s position) from left (out of the mask) to right(the original position, where the mask is)
    I’ve everything working, but I’d like to know if the line “init” could have an expression in which it’s always the final position minus the content shape’s size.. now I’m doing it by hand depending on the width of the letter, but I’m wondering if it could be done more universal

    this is the (dirty, but working) expression applied to the letter (which is a shape layer)’s content position

    t = time-inPoint;
    L=thisComp.layer("control");
    s = L.effect("move")("Slider");
    ende=content(1).transform.position[0];
    init=ende/1.5
    v0 = s.valueAtTime(L.inPoint);
    v1 = s.valueAtTime(L.inPoint+t);
    po=v1-v0;
    j=linear(po,0,100,init,ende);

    [j,value[1]]

    I hope it could be done! I’ve tried several things, but never worked…
    thanks!

    Peter Zeet replied 10 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Kalleheikki Kannisto

    May 9, 2016 at 8:59 am

    You can get the width of a layer content including text layers with

    thisLayer.sourceRectAtTime().width

    If you have a single letter on a layer, whether a shape layer or a text layer, that will return the width of the letter.

    (AECC2014.2 and above)

  • Peter Zeet

    May 10, 2016 at 2:22 am

    Oh, many thanks!! worked perfectly!

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