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

expression, lock only scale the Y axis.

New Here ,
May 25, 2019 May 25, 2019

I'm using a expression that locks scale of layer even when scaling the parent.

I need to lock only scale the Y axis.

Can someone help?

L = thisLayer;

s = transform.scale.value;

while (L.hasParent){

L = L.parent;

for (i = 0; i < s.length; i++) s[1,i] *= 50/L.transform.scale.value[1,i]

}

s

7.6K
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 , May 25, 2019 May 25, 2019

Scale is an array [x, y, z] for 3D layers. x [0], y is [1], and z is [2]. If the layers are 2D then all you need to do is use the s[0] value for x and the existing value for y.

Here's how to do that:

L = thisLayer;

s = transform.scale.value;

while (L.hasParent){

L = L.parent;

for (i = 0; i < s.length; i++) s[1,i] *= 50/L.transform.scale.value[1,i]

}

[s[0], value[1]]

Now any value you enter or even animate for y will not be affected by the scale of the parent.

Translate
Community Expert ,
May 25, 2019 May 25, 2019

Scale is an array [x, y, z] for 3D layers. x [0], y is [1], and z is [2]. If the layers are 2D then all you need to do is use the s[0] value for x and the existing value for y.

Here's how to do that:

L = thisLayer;

s = transform.scale.value;

while (L.hasParent){

L = L.parent;

for (i = 0; i < s.length; i++) s[1,i] *= 50/L.transform.scale.value[1,i]

}

[s[0], value[1]]

Now any value you enter or even animate for y will not be affected by the scale of the parent.

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 ,
May 25, 2019 May 25, 2019

Thank you for helping me learn.

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 ,
May 16, 2025 May 16, 2025
LATEST

Hey Rick

How would one adapt / flip this this expression to only allow scaling in the x axis instead of the y axis? 

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