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

Need help. How to write If/Else expression to change position value based on size value.

New Here ,
May 19, 2024 May 19, 2024

Copy link to clipboard

Copied

Hello AE friends!

I need your helping writing an if/else statement to adjust the position of a layer based on the size value of another layer. Is it even possible?!

 

I am creating a .mogrt lowerthird and I am trying to add an if/else conditional statement so the client has the option to add an extra line of text under 'Occpation job title'. If they add the extra line of text, the 'organisation' text layer below, needs to shift down so a gap remains between the two text boxes. Else, it stays where it is.

 

Lowerthird-1.PNG

 

So if 'Text box' Shape layer size height value is greater than 90.9, 'Organisation' text layer y position is 27.3. Else y position is 14.7

 

Here is my current expression added to the y position value of the text layer 'Organisation'

 

s = thisComp.layer("Text box").content("Rectangle 1").content("Rectangle Path 1").size;

y = s.height;
if(y>90.9){(27.3)}
else{(-14.7)};

 

No error has come up, but it's definitely not working as nothing changes when I add an extra line of text. In the screenshot below you can see the size value of 'Text box' layer has changed but the y position of 'Organisation' text layer has remained in the else value -14.7.

Lowerthird-2.PNG

 

I have set up expressions on the 'text box' shape layer so it auto adjusts to two different text layers. So when I add the extra line of text, the size value of the text box changes automatically. Could this be interfering with the if/else expression?

 

I am not very familiar with writing expressions for size and position values so any help is greatly appreciated. I have attached my AE file for you all to fiddle with.

 

Looking forward to your responses. Thanks heaps!

 

 

 

 

TOPICS
Error or problem , Expressions , How to , Scripting

Views

160

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 Expert , May 19, 2024 May 19, 2024

I think you just need to change:

y = s.height;

to:

y = s[1];
		

 

Votes

Translate

Translate
Community Expert ,
May 19, 2024 May 19, 2024

Copy link to clipboard

Copied

I think you just need to change:

y = s.height;

to:

y = s[1];
		

 

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
New Here ,
May 19, 2024 May 19, 2024

Copy link to clipboard

Copied

LATEST

That worked! Thank you so much

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