Skip to main content
Participant
November 6, 2023
Answered

How to lock a property

  • November 6, 2023
  • 1 reply
  • 1344 views

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.

This topic has been closed for replies.
Correct answer Rick Gerard

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.

1 reply

Rick GerardCommunity ExpertCorrect answer
Community Expert
November 6, 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.

Participant
November 6, 2023

Hi and thank you for your respoce.

I tried the first example and it gives me this message. What am i doing wrong?

Community Expert
November 7, 2023

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