Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scale layer based on another object’s position

  • Scale layer based on another object’s position

    Posted by Bryan Woods on March 2, 2016 at 4:48 pm

    I always forget how to do this, and I never seem to write it down.

    Imagine a layer in AE. If you pull on the edge of that layer, you expand the layer out as far as you pull it.

    I’m trying to do the same with a rectangle and an object on its right. If I pull the object out to the right, the rectangle needs to scale x out at the same rate that I moved the object.

    I thought linear() would do it, but realized that just sets a range. I need to be able to stretch this out as much or as little as I need it. The rectangle’s anchor is set to left center edge so scaling works properly on x.

    Can someone refresh my memory on the process for this? Thanks.

    Bryan Woods replied 10 years, 5 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    March 2, 2016 at 5:23 pm

    This might work, depending on how you have things set up:

    L = thisComp.layer(“object”);
    d = L.toComp([0,0])[0] – toComp([0,0])[0];
    s = (d/width)*100;
    [s,s]

    Dan

  • Bryan Woods

    March 2, 2016 at 10:39 pm

    Hmm, not quite. As I pull object out, rectangle scales, but at a slower rate than object. Ideally the scale of rectangle should be that the edge of rectangle looks like its attached to object as its pulled out.

  • Dan Ebberts

    March 2, 2016 at 10:45 pm

    It should work if your two objects are solid layers that aren’t rotated or masked. Shape or text layers, or anything involving rotation and/or masking would be a different story.

    Dan

  • Bryan Woods

    March 3, 2016 at 12:35 am

    Ah, I should have been more specific then. Rectangle is a shape layer with its anchor positioned to middle left. The object is also another shape layer.

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