I had a good day today and answered my own question.
Here is the code:
Code: Select all
//Gridify comps.
//Takes selected footage item and creates multiple comps that are windows into the footage item.
//Guts from Compify
//Byron Nash, Edited and Improved by Paul Tuersley
//October 2004
//
//Select single footage items to be gridified.
{ //opening brace
var proj = app.project;//set project
// create undo group if user didn't cancel dialog
app.beginUndoGroup("Gridify_Comp");
var projColl = proj.items;//list of items in project
writeLn("Grid RECT Comps");
var myComps = new Array();//array for storing all the comps made
var selItems = app.project.selection;//set selected import items to an array
if (selItems.length > 0){//check to see if anything is selected
var myColl = app.project.selection;//if so the use the selection
var i = 0;
} else {//if not, use entire project contents
var myColl = new Array();
for (j=0; j < projColl.length; j++){//add project list to an array
myColl[j] = projColl[j+1];
}
}
//Specify your number of comps needed here.
var gridWidth = 4;
var gridHeight = 2;
for (y=0; y < gridHeight; y++) {
for (x=0; x < gridWidth; x++) {
var suffix = stillInfo[0];//get suffix from array
for (i=0; i <= myColl.length; i++) {//loop through the project
var curItem = myColl[i];
if (curItem instanceof FootageItem) {//check for footage items
var extPos = curItem.name.lastIndexOf(".");//find file extension
//add suffux to comp name and remove the file extension
suffix = "(" + x + "x" + y +")";
var curName = curItem.name.substring(0, extPos) + "_" + suffix;
//Truncate comp name if it exceeds the 31 character limit
if (curName.length > 30){
curName = curName.slice(0,29-suffix.length) + "_" + suffix;
}
//setup comp variables
var curWidth = curItem.width/gridWidth;
var curHeight = curItem.height/gridHeight;
var curAspect = curItem.pixelAspect;
var curDuration = curItem.duration;
var curRate = curItem.frameRate;
if (curDuration == 0){
curDuration = stillInfo[2] //set duration to dialog value if it is a still image
}
if (curRate < 1){
curRate = stillInfo[1]//set frame rate to dialog value if it is a still image
}
//create comp and add layer
var newComp = projColl.addComp(curName,curWidth,curHeight,curAspect,curDuration,curRate);//make new comp
var lcoll = newComp.layers;//variable for collection of layer objects in logoComp
//Add layer.
var curLayer = lcoll.add(curItem);
//Position it to the appropriate place in the grid.
myPosition = curLayer.property("position");
//myPosition.setValueAtTime(0,[(curWidth/2)-(x * curWidth),(curHeight/2)-(y * curHeight)]);
myPosition.setValueAtTime(0,[(curItem.width/2)-(x * curWidth),(curItem.height/2)-(y * curHeight)]);
myComps[myComps.length] = newComp;//add comp to array
}
}
}
}
writeLn("Created " + myComps.length + " Comps");
app.endUndoGroup();
}//closing
I took the guts out of compify and adjusted it as needed.
USAGE:
Select a single footage item and run the script.
OUTPUT:
It will create a series of comps with a single layer (the one you selected) in the comp. The position of the layer is offset so that if you were to render each comp, you would have a window into the original footage item offset by the position in the grid.
ToDo:
Automatically add these new comps to the render que? ( I guess I'll be digging around for code to do that)