Skip to main content
Participant
May 25, 2019 4:56 PM UTC
Answered

expression, lock only scale the Y axis.

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

    Rick GerardCorrect answer
    Community Expert
    May 25, 2019 5:33 PM UTC

    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.

    3 replies

    Rick GerardCommunity ExpertCorrect answer
    Community Expert
    May 25, 2019 5:33 PM UTC

    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
    Participant
    May 25, 2019 5:50 PM UTC

    Thank you for helping me learn.

    Translate