can an expression do this?

Moderators: Disciple, zlovatt

Post Reply
Varangian
Posts: 38
Joined: December 16th, 2004, 11:15 am

is this possible with an expression...

I need a layer (layer B) to follow in position another layers (layer A) right edge.

So when Layer A is scaled, Layer B moves in space to follow the right edge of layer A. The same would go for when Layer A is rotated or repostioned, Layer B would stay snapped to layer A's right edge.

I can not use parenting here, because I do not want the layer B to be scaled by layer A, only re-po'd.

this make sense?
basically I am creating a rainbow ribbon in many segments that I need to accordion, and want to stretch certain sections longer than others, while maintaining the connections. The thickness (height) of the ribbon can not change.
Mylenium
Posts: 139
Joined: July 20th, 2005, 12:07 am

Varangian wrote:is this possible with an expression...
Sure it is. you simply multiply the initial position by the scale factor e.g.


p_pos_x=p_size_x=thisComp.layer("Parent").position[0];
p_pos_y=p_size_x=thisComp.layer("Parent").position[1];
p_scale=thisComp.layer("Parent").scale[0]/100;

X=p_pos_x+position[0]*p_scale;
Y=p_pos_y+position[1];

[X,Y]


To automatically place items, you can simply use the dimensions of the parent layer


p_pos_x=p_size_x=thisComp.layer("Parent").position[0];
p_pos_y=p_size_x=thisComp.layer("Parent").position[1];
p_size_x=thisComp.layer("Parent").width;
p_size_y=thisComp.layer("Parent").height;
p_scale=thisComp.layer("Parent").scale[0]/100;

X=p_pos_x+p_size_x*p_scale;
Y=p_pos_y+p_size_y*0.5;

[X,Y]


For the rotation simply use the opposite value of the parent layer. Depending on the complexity you#re after, you may need to use layer psace transforms as opposed to hard-coded derived values.

Mylenium
[Pour Mylène, ange sur terre]
Post Reply