ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Inherit only position property from parent

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Obed Ampong
Inherit only position property from parent
on May 30, 2019 at 2:51:11 pm

Hello,
Is it possible to make a child inherit only position properties from the parent without the scale properties? I need to move the position of the child with the parent however want to maintain the scale of the child even if the parent scale properties change.
Thank you.
Obed


Return to posts index

Miguel de Mendoza
Re: Inherit only position property from parent
on May 30, 2019 at 3:37:01 pm

Try this on child position:

parentPosition = thisComp.layer("Parent Layer Name").transform.position;
value + parentPosition // Remove this line if you need locked child


Return to posts index

Obed Ampong
Re: Inherit only position property from parent
on May 30, 2019 at 4:01:05 pm

Hi,

thanks, It works

Regards,
Obed


Return to posts index


Obed Ampong
Re: Inherit only position property from parent
on May 31, 2019 at 9:43:35 am

Please, is it also possible to keep equidistance between them all the time?


Return to posts index

Obed Ampong
Re: Inherit only position property from parent
on May 30, 2019 at 4:33:35 pm

Please, what if I want the child position[0] to be affected by the scale.
For example, the parent is a bar graph and the child is the label( %). I would like to keep the distance between the graph and the label (%) so that if I increase the scale of the bar the label will move a little further away from its position, however, I would like to keep the position[1]of the label(%) freely so that it can inherit the position[1] of the bar graph.
Thank you


Return to posts index

Miguel de Mendoza
Re: Inherit only position property from parent
on May 30, 2019 at 5:19:56 pm

For plain relatinships, just change position by the property you want to parent:

parentPosition = thisComp.layer("Parent Layer Name").transform.position;
parentScale = thisComp.layer("Parent Layer Name").transform.scale;
parentOpacity = thisComp.layer("Parent Layer Name").transform.opacity;
parentScaleX =parentScale[0];
////and so on ....


For what you are looking for explicitly:

thisParent = thisComp.layer(""Parent Layer Name"");
parentPos = thisParent.transform.position;
parentScaleWidth = thisParent.transform.scale[0];
toRight = thisParent.width/2 * parentScaleWidth/100 + parentPos[0];
[toRight + value[0], value[1]]


Return to posts index


Obed Ampong
Re: Inherit only position property from parent
on May 31, 2019 at 3:48:40 am

Hi Miguel,
Thanks for the reply, it worked but is it possible to factor in the anchor point? I have my anchor point set to the extreme left of the parent while the child is at the extreme right end.
regards,
Obed


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]