Last active
August 29, 2015 14:03
-
-
Save dokluch/830e93ae96e841d65f58 to your computer and use it in GitHub Desktop.
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
//CC-BY Nik Ska, 2014 | |
var sel = app.project.selection; //selected | |
var used = []; //these were used | |
app.beginUndoGroup("Precomping as hell"); | |
var precompFolder = app.project.items.addFolder("Precomps"); | |
for(var c = 1; c <= Math.ceil(sel.length/10); c++){ | |
//creating comps | |
var newComp = app.project.items.addComp("Precomp " + c, sel[0].width, sel[0].height, sel[0].pixelAspect, sel[0].duration, sel[0].frameRate); | |
newComp.parentFolder = precompFolder; | |
var count = 1; | |
while(count <= 10){ | |
var r = Math.floor(Math.random()*sel.length); //random num | |
if(!used.isThere(r)){ //if this number hasn't been used | |
newComp.layers.add(sel[r]); //add the corresponding comp to precomp | |
used.push(r); //mark it as used | |
count++; | |
} | |
} | |
} | |
app.endUndoGroup(); | |
Array.prototype.isThere = function(el){ | |
for(var i = 0; i<this.length; i++){ | |
if(this[i] === el) return true | |
} | |
return false | |
} |
Author
dokluch
commented
Jun 29, 2014
- Select N comps, where N is divisible by 10
- Script creates N/10 precomps
- Each precomp contains 10 random unique selected comps.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment