Skip to main content
Participant
Nov 6, 2023 12:38 PM UTC
Answered

How to lock a property

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 is closed to new replies. Start a new post to keep the conversation going.
Rick GerardCorrect answer
Community Expert
Nov 6, 2023 1:29 PM UTC

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.

4 replies

Rick GerardCommunity ExpertCorrect answer
Community Expert
Nov 6, 2023 1:29 PM UTC

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
Participant
Nov 6, 2023 8:26 PM UTC

Hi and thank you for your respoce.

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

Translate
Community Expert
Nov 7, 2023 12:03 AM UTC

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

Translate