ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Linking a Shape Layer's Size (X) to the Position of a Null Object (X)

FAQ   •   VIEW ALL
 Linking a Shape Layer's Size (X) to the Position of a Null Object (X) on Aug 30, 2018 at 8:18:41 pm

Okay so I'm definitely new to expressions other than finding what I need through relentless internet searching. But I can't seem to find what I'm trying to do here.

So I have a rectangle layer's x size that I want to connect to a null objects position in x. So when the rectangle gets bigger in X the null object will move to the left on the X axis.

Thanks!

 Re: Linking a Shape Layer's Size (X) to the Position of a Null Object (X)on Aug 31, 2018 at 7:32:47 am

Just because I might have missed read this.

If you want, when the shape width gets bigger and extends to the left. You need your anchor point to be situated to the right hand side.

So in anchor point of your layer.

r = sourceRectAtTime();
[r.left + r.width, r.top + r.height/2]

then pick whip the position to the null.

Alternatively, if you want the position to move rather than the shape extending.

I'd still use the anchor point expression as the anchor won't sit still when it changes.

Then in the position. I don't know how much you want to move it by, which makes me think you want the 1st option.

x = thisComp.layer("Null 1").transform.position[0] - content("Rectangle 1").content("Rectangle Path 1").size[0];
y = value[1];
[x,y]

If you want it to start on the anchor point of the null, then you have to make some alterations.

Hope that helps