Skip to content

Instantly share code, notes, and snippets.

@u27a4
Created April 14, 2019 13:34
Show Gist options
  • Save u27a4/9d2747396db9436f7086105fb939ab15 to your computer and use it in GitHub Desktop.
Save u27a4/9d2747396db9436f7086105fb939ab15 to your computer and use it in GitHub Desktop.
aescript; snap selected layers to the corner in composition.
function snap (x, y)
{
var item = app.project.activeItem;
var layerIndicies = [];
for (var i = 0; i < item.selectedLayers.length; i++)
{
layerIndicies.push(item.selectedLayers[i].index);
}
item.layers.precompose(layerIndicies, item.selectedLayers[0].name, true);
var precomposed = item.selectedLayers[0];
precomposed.transform.scale.setValue([50, 50]);
precomposed.transform.anchorPoint.setValue([
[[item.width, item.height,], [0, item.height,]],
[[item.width, 0, ], [0, 0, ]],
][y][x]);
}
app.beginUndoGroup("snap");
snap(0, 0);
app.endUndoGroup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment