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

How to lock a property

New Here ,
Nov 06, 2023 Nov 06, 2023

Hello. im trying to lock a layers property from moving on Y axis. I want it to move only on X and not on Y. Not even by accident and not even if it is lincked to another layer. I cant find any informatin anyware. Can someone help?

Thank you.

TOPICS
Expressions
1.0K
Translate
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 , Nov 06, 2023 Nov 06, 2023

For simple position animation with no parent layer all you have to do is enter the desired value of the Y position in a simple array. If you wanted the Y value to always be 300 the expression would look like this:

[value[0], 300];

 If the layer is the child of another layer (Parented), then you subtract the toComp(anchorPoint) of the anchor point from your desired Y position like this:

tPos = parent.toComp(anchorPoint);
[value[0], 300 - tPos[1]]

 That will make the X position follow the Null and

...
Translate
Community Expert ,
Nov 06, 2023 Nov 06, 2023

For simple position animation with no parent layer all you have to do is enter the desired value of the Y position in a simple array. If you wanted the Y value to always be 300 the expression would look like this:

[value[0], 300];

 If the layer is the child of another layer (Parented), then you subtract the toComp(anchorPoint) of the anchor point from your desired Y position like this:

tPos = parent.toComp(anchorPoint);
[value[0], 300 - tPos[1]]

 That will make the X position follow the Null and hold the Y position at 300. 

 

You can throw in an if/else statement that looks for a parent layer like this:

if(thisLayer.hasParent){
	tPos = parent.toComp(anchorPoint);
	[value[0], 300 - tPos[1]];
}
else{
	[value[0], 300]
}

That way you only have to write one expression.  You could also tie the Y position to an expression control slider.

 

If those two solutions don't solve your problem then we need a screenshot showing exactly what you need and a detailed workflow and design description.

Translate
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 ,
Nov 06, 2023 Nov 06, 2023

Hi and thank you for your respoce.

I tried the first example and it gives me this message. What am i doing wrong?Screenshot 2023-11-06 222344.png

Translate
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
Community Expert ,
Nov 06, 2023 Nov 06, 2023

Do not separate values. It is almost always a bad idea to do so. 

Translate
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 ,
Nov 07, 2023 Nov 07, 2023
LATEST

Thank you. If not separated, it worked!

Translate
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