Skip to main content
Participant
May 25, 2019
Answered

expression, lock only scale the Y axis.

  • May 25, 2019
  • 1 reply
  • 7728 views

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

    Correct answer Rick Gerard

    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.

    1 reply

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

    Participant
    May 25, 2019

    Thank you for helping me learn.