Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions snapping with expressions?

  • snapping with expressions?

    Posted by Sorbet on October 24, 2006 at 11:29 pm

    This should be easy. I’m trying to figure out a way (through expressions) that I can snap to different px increments. For example, if you keyframed a square to move from left to right, it would snap to 100px increments.

    I realize you can snap to guides or the grid, but I’d like to have it snap constantly, even when you animate something.

    Any ideas?

    Sorbet replied 19 years, 6 months ago 3 Members · 3 Replies
  • 3 Replies
  • Colin Braley

    October 25, 2006 at 12:04 am

    This should do it for you:

    xSnap = 100;
    ySnap = 100;
    [ Math.round(value[0]/xSnap) * xSnap , Math.round(value[1]/ySnap) * ySnap ]

    Just change xSnap and ySnap to whatever increments you want to snap to. However, note that sometimes if you have an object animated near the edge of the comp it might snap to a value out of the comp window. Have fun.

    ~Colin

  • Filip Vandueren

    October 25, 2006 at 12:08 am

    for a hard snap use this:

    for a 2D-layer:
    [Math.round(value[0]/100),Math.round(value[1]/100)] * 100;

    for a 3D layer:
    [Math.round(value[0]/100),Math.round(value[1]/100),Math.round(value[2]/100)] * 100;

    so it divides each co

  • Sorbet

    October 25, 2006 at 12:48 am

    Thanks guys! Works perfect!

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