• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Expressions problem with offsetting position of layer B vs layer A

Community Beginner ,
Jul 07, 2017 Jul 07, 2017

Copy link to clipboard

Copied

Heyah

I am building a Essential Graphics text template and I need to attach B layer to corner of A layer + offset it downwards.

Let me explain:

A layer is a text layer. I am using this expression to keep anchor point dead centre, even if text changes.

R = thisLayer.sourceRectAtTime(time); T = R.top; L = R.left; W = R.width; H = R.height; [L+W/2,T+H/2] 

Also, I am using this expression to keep the position of text layer A fixed at all times:

var w=thisComp.width; var h=thisComp.height; var w2=w/2; var h2=h/6; [w2,h2*2] 

So far so good. Stuff works. Now, the part I have problem with is to adjust position of layer text B, based on a textbox of a layer A. I want it to be offset dynamically. At the moment, the expressions I managed to come up with work, but then when I add or remove characters to text layer A, it gets messed up.

boxHeight =thisComp.layer("Text layer A.").sourceRectAtTime(time).height; boxWidth = thisComp.layer("Text layer A.").sourceRectAtTime(time).width; boxLeft = thisComp.layer("Text layer A.").sourceRectAtTime(time).left; [-boxLeft,boxHeight]; 

Short version: how can I attach layer B to the bottom left corner of a layer A + offset it downward by 20 pixels?

Any ideas?

Kamil

Views

876

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Jul 07, 2017 Jul 07, 2017

I found the solution after digging in more with a code.

Add this to the position property. It will use layer A (1 layer above layer B) to offset position based on a layer A's height and width.

boxHeight = thisComp.layer(index-1).sourceRectAtTime().height;

boxWidth = thisComp.layer(index-1).sourceRectAtTime().width;

thisComp.layer(index-1).position + [-boxWidth/2,boxHeight*1.3];

Votes

Translate

Translate
Community Beginner ,
Jul 07, 2017 Jul 07, 2017

Copy link to clipboard

Copied

LATEST

I found the solution after digging in more with a code.

Add this to the position property. It will use layer A (1 layer above layer B) to offset position based on a layer A's height and width.

boxHeight = thisComp.layer(index-1).sourceRectAtTime().height;

boxWidth = thisComp.layer(index-1).sourceRectAtTime().width;

thisComp.layer(index-1).position + [-boxWidth/2,boxHeight*1.3];

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines