View all expressions
Transformation

Dynamic Anchor Point Lock Expression

Uses sourceRectAtTime() and a dropdown menu to lock a layer’s anchor point to any of nine positions (center, corners, edges) relative to its own bounds.

Contributed by:


// Fetch the dropdown value
anchorOption = effect("Dropdown Menu Control")("Menu");
// Get the text bounds
rect = sourceRectAtTime((inPoint+outPoint)/2, false);
top = rect.top;
left = rect.left;
w = rect.width;
h = rect.height;
// Default values
x = 0;
y = 0;
// Anchor point switch
if (anchorOption == 1) {
// Center  x = left + w/2;
y = top + h/2;
} else if (anchorOption == 2) {
// Top Left  x = left;
y = top;
}
else if (anchorOption == 3) {
// Top  x = left + w/2;
y = top;
}
else if (anchorOption == 4) {
// Top Right  x = left + w;
y = top;
}
else if (anchorOption == 5) {
// Right  x = left + w;
y = top + h/2;
} else if (anchorOption == 6) {
// Bottom Right  x = left + w;
y = top + h;
}
else if (anchorOption == 7) {
// Bottom  x = left + w/2;
y = top + h;
}
else if (anchorOption == 8) {
// Bottom Left  x = left;
y = top + h;
}
else if (anchorOption == 9) {
// Left  x = left;
y = top + h/2;
}
[x, y];

Dynamic Anchor Point Lock Expression

Practical use case

Quickly snap a layer’s Anchor Point to any corner or the center without dragging it by hand. Great for lower-thirds and text rigs.

Check out similar expressions

Data-driven video workflows for After Effects are easier with Plainly.

a mesh of elegant lines transparent image