How to Get Correct Text Layer Size in After Effects

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ค. 2024
  • In this tutorial, Sergei will show you how to get the correct text layer size using Expressions in After Effects.
    Project File & Code: ukramedia.com/how-to-get-corr...
    Expressions Course: ukramedia.com/expressions
    Blender Course: ukramedia.com/blender
    ______________________________________________________________
    CODE FOR WIDTH:
    targetLayer = thisComp.layer("Layer Name");
    w = targetLayer.sourceRectAtTime().width;
    s = targetLayer.transform.scale[0];
    p = (s - 100)* .01;
    finalSize = w + p * w;
    finalSize
    ______________________________________________________________
    CODE FOR HEIGHT:
    targetLayer = thisComp.layer("Layer Name");
    h = targetLayer.sourceRectAtTime().height;
    s = targetLayer.transform.scale[1];
    p = (s - 100)* .01;
    finalSize = w + p * h;
    finalSize
    ______________________________________________________________
    LINKS:
    Ukramedia Website: ukramedia.com
    Shape Layers in After Effects Tutorial: • Shape Layers in After ...
    Ukramedia Podcast: ukramedia.com/category/podcast/
    Ukramedia Mentoring Group: / ukramedia
    ML3RD KIT - Bundle: www.ukramedia.com/ML3RD
    ML3RD KIT - Flat Style: ukramedia.com/product/modular...
    ML3RD KIT - Corporate Style: ukramedia.com/product/modular...
    ML3RD KIT Batch Duplicator: www.ukramedia.com/ML3RD
    Get Adobe After Effects and CC: clk.tradedoubler.com/click?p(...)
    Get Adobe CC Trial: clk.tradedoubler.com/click?p(...)
    Get Adobe CC Student: clk.tradedoubler.com/click?p(...)
    Find The Perfect Asset For Your Next Creative Project: clk.tradedoubler.com/click?p(...)
    LET’S CONNECT:
    Facebook: / ukramedia
    Sergei's Facebook Page: / sergeiprokhnevskiy
    Twitter: / ukramedia
    Instagram: / ukramedia
    Pinterest: / ukramedia
    Linkedin: / ukramedia
    TH-cam: / ukramedia
    Mailing Address:
    P.O. Box 621
    Huntersville, NC 28070
    *** MUSIC BY: VLAD SOLOKHA. Vlad is a family friend who is a very talented musician. You can reach out to him by going to his facebook at vlad.solokha....
    #AfterEffects #Expressions #MoGraph

ความคิดเห็น • 29

  • @krithivasramamurthy4838
    @krithivasramamurthy4838 2 ปีที่แล้ว +1

    Thank you Sergei!

  • @DaleplayUy
    @DaleplayUy 2 ปีที่แล้ว +6

    Great tutorial! After finishing it, I´ve made a simplified version of the code:
    yourTextLayer = thisComp.layer("text");
    x = yourTextLayer.sourceRectAtTime().width * yourTextLayer.transform.scale[0]/100;
    y = value[1];
    [x,y];

    • @andrewj22
      @andrewj22 ปีที่แล้ว

      Yeah, the expression provided is unnecessarily convoluted.

  • @Climberfx
    @Climberfx 2 ปีที่แล้ว +2

    Great, thank you!

  • @SashaFromSaintP
    @SashaFromSaintP 5 ปีที่แล้ว +1

    Instant like to Sergei!

  • @RHStevens1986
    @RHStevens1986 5 ปีที่แล้ว +4

    Literally looking for this solution in the last 24 hours

  • @bolshooylenny
    @bolshooylenny 4 ปีที่แล้ว +2

    Hi Sergey, can you tell please what plugin or extension you use in expressions console because in your video I saw interactive expressions and menus with operators, it is like in sublime text editor, please suggest where I can find it?

  • @ovidiumurzea
    @ovidiumurzea 3 ปีที่แล้ว +1

    What if I add a space at the end of the word? How can I make the shape extend so it underlines the space character as well?

  • @BenAha
    @BenAha 3 ปีที่แล้ว +7

    there's an error in height code. should be:
    CODE FOR HEIGHT:
    ...
    finalSize = h + p * h;

  • @IDMovieZwijndrecht
    @IDMovieZwijndrecht 5 ปีที่แล้ว +1

    You're on a roll! Thanks bro!

    • @ukramedia
      @ukramedia  5 ปีที่แล้ว

      Thank YOU! 😁

  • @vinteeum
    @vinteeum 5 ปีที่แล้ว +3

    how can I do this but using a composition instead of a shape?

  • @pilemedya
    @pilemedya 4 ปีที่แล้ว +1

    hi thank you great job but your script does not work in my after fx 2020 do you know why can you help me
    targetLayer = thisComp.layer("mavianemon");
    this line mostly error
    w = targetLayer.sourceRectAtTime().width;
    and this too if i delete other line

  • @user-rx6yw4pb3t
    @user-rx6yw4pb3t 9 หลายเดือนก่อน

    Surely if you parented the underline to the text layer - it would simply follow the scale of the text layer?

  • @steilvorlageDE
    @steilvorlageDE 6 หลายเดือนก่อน

    Great stuff, but why didn't you pickwhip the scale and multiplied it with x/100?

  • @keithhopkin
    @keithhopkin 4 ปีที่แล้ว +1

    Just saved my life

    • @ukramedia
      @ukramedia  4 ปีที่แล้ว

      That's great to hear! Thanks for watching, Keith!

  • @nickjames5602
    @nickjames5602 6 หลายเดือนก่อน

    I copied this code verbatim word for word and can't get anything to work. Is this code still valid in 2024 with After Effects 2024?

  • @KanugulaRohith
    @KanugulaRohith 4 ปีที่แล้ว

    Your video card does not support the selected configuration please reduce the layer size

  • @VideofoundryNet
    @VideofoundryNet 3 ปีที่แล้ว +1

    p = (s - 100) * .01
    finalSize = w + p * w
    This is the same as:
    finalSixe = s * .01 * w
    So all you have done is to scale w by the scale parameter?

    • @andrewj22
      @andrewj22 ปีที่แล้ว

      Exactly what I was going to say. It's an unnecessarily convoluted way of calculating it.
      Why would you subtract 100 from the percent in one line, then add it back in ("w +") in the next?? Bizarre.

  • @HuyLe2607
    @HuyLe2607 4 ปีที่แล้ว

    But it's suitable for text that aligns center only. With aligning left and right, the shape does not work. :(

    • @ChupoCro
      @ChupoCro 2 ปีที่แล้ว +1

      For left aligned text you have to move the anchor point of the line (rectangle shape) to the left. For example if you have a layer "Letters" with the text and another layer with Rectangle 1 shape for the line then the expressions would be:
      Rectangle path size:
      [thisComp.layer("Letters").sourceRectAtTime().width, value[1]]
      Transform: Rectangle 1 anchor point:
      [-content("Rectangle 1").content("Rectangle Path 1").size[0]/2, 0]
      Transform:
      thisComp.layer("Letters").transform.position

    • @BroskiiFX
      @BroskiiFX 2 ปีที่แล้ว

      @@ChupoCro Where would this go along with his coding? I'm a little lost here.

  • @daryljudd9190
    @daryljudd9190 5 ปีที่แล้ว +2

    Nice script, but wouldn't a simpler way be to just parent the shape layer to the text layer? That's how I've done it.

    • @andrewj22
      @andrewj22 ปีที่แล้ว

      Parenting combined with the expression would behave differently; for one, the line wouldn't stay the same thickness when scaling. Or, if you're suggesting just parenting with no expression at all, then when you want to create a second version with different text, the box wouldn't be the right size.

  • @osalomono
    @osalomono 4 ปีที่แล้ว +1

    It is likely that anyone watching this type of video is an advanced expressions user or writer, you don't have to waste time explaining how Array values work, or that the position property is defined using arrays. Hopefully this is not the case of padding your video to reach a particular duration. Better time could have been spent explaining the Math behind the finalSize value.
    Thanks for sharing

    • @WolfGodwin
      @WolfGodwin 2 ปีที่แล้ว +2

      It is thanks to Ukramedia not assuming people know everything about expressions that I am able to learn more and increase my productivity in AE.