Created
April 21, 2019 14:12
-
-
Save u27a4/e1c76d09037ce2a1b6606e68a0b3080d to your computer and use it in GitHub Desktop.
aescript; arrange selected layers in a grid.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gridarrange(comp, layerIndicies) | |
{ | |
var d = Math.ceil(Math.sqrt(layerIndicies.length)); | |
var w = comp.width / d; | |
var h = comp.height / d; | |
for (var i = 0; i < layerIndicies.length; i++) | |
{ | |
var x = i % d; | |
var y = Math.floor(i / d); | |
comp.layers.precompose([layerIndicies[i]], comp.layers[i+1].name, true); | |
var precomposed = comp.layers[layerIndicies[i]]; | |
precomposed.transform.scale.setValue([100 / d, 100 / d]); | |
precomposed.transform.position.setValue([w / 2 + w * x, h / 2 + h * y]); | |
} | |
} | |
app.beginUndoGroup("gridarrange"); | |
var item = app.project.activeItem; | |
var layerIndicies = []; | |
for (var i = 0; i < item.selectedLayers.length; i++) | |
{ | |
layerIndicies.push(item.selectedLayers[i].index); | |
} | |
gridarrange(item, layerIndicies); | |
app.endUndoGroup(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment