Forum Replies Created

  • You can unparent a layer using this recursive function, e.g. fix (value, thisLayer)

    function fix ( pos , layer ) {
    if (layer.hasParent) {
    var p=layer.parent;
    pos = fix ( pos , p );
    var rp = degreesToRadians(p.rotation);
    var delta = pos – p.position;
    var s = p.scale / 100;
    delta = [ delta[0] / s[0] , delta[1] / s[1] ];
    rad = Math.sqrt ( delta[0]*delta[0] + delta[1]*delta[1] );
    if (delta[1] != 0) ang = Math.atan (delta[0]/delta[1]) else ang = Math.PI/2;
    dx = Math.sin (ang+rp) * rad;
    dy = Math.cos (ang+rp) * rad;
    if (delta[1]<0) {dx=-dx; dy=-dy};
    return [dx,dy] + p.anchorPoint;
    }
    else return pos;
    }

  • Daniele De luca

    March 26, 2015 at 10:15 pm in reply to: Unparent layer at certain frame???

    There’s also a way to unparent with expression. In some cases that gives you more freedom to manipulate the layer, more than splitting the layer. You only have to put this fix function on the position of the parented layer. When you call it you have to specify the absolute position (that can be keyframed if you use “value” as input) and the layer that you want to unparent, e.g. : fix ( value , thisLayer).

    function fix ( pos , layer ) {
    if (layer.hasParent) {
    var p=layer.parent;
    pos = fix ( pos , p );
    var rp = degreesToRadians(p.rotation);
    var delta = pos - p.position;
    var s = p.scale / 100;
    delta = [ delta[0] / s[0] , delta[1] / s[1] ];
    rad = Math.sqrt ( delta[0]*delta[0] + delta[1]*delta[1] );
    if (delta[1] != 0) ang = Math.atan (delta[0]/delta[1]) else ang = Math.PI/2;
    dx = Math.sin (ang+rp) * rad;
    dy = Math.cos (ang+rp) * rad;
    if (delta[1]&lt;0) {dx=-dx; dy=-dy};
    return [dx,dy] + p.anchorPoint;
    }
    else return pos;
    }

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy