After Effects scripting library
From Mographwiki.net
AE scripting for MEL maya scripters
Yes, its a specific category, but thats me... hopefully this'll be of use to anyone who can script in another language.
- To open a simple popup box: alert("hello world");
- To just print to the console (handy for debugging without halting flow): $.writeln("hello world");
- To print to the info window (like using the info line in maya): write("boo");
- To print to the info window with a new-line: writeLn("boo");
- The current project array of objects: app.project.items
- List all the items in the current project:
var meItems = app.project.items;
var totalItems = meItems.length;
for (var i=1; i<meItems.length; i++) {
$.writeln("item:[" +i+ "] is " + app.project.item(i).name);
}
this returns
item:[1] is 0_fina item:[2] is 0_fin.tif item:[3] is 010.jpg item:[4] is ad item:[5] is ad.iff item:[6] is Comp 1 item:[7] is Solids item:[8] is Black Solid 1
- Get the name of layer 8 in a comp (note the array index is the same as the layer number): app.project.item(6).layer(8).name
Auto slate generator
Early days, but this is working well so far. Our image sequences out of 3d are named in the format sequence_camera_shot_take_artist.####.jpg, this script takes that info and updates an existing slate template. Will expand to also read in lens info from a text file generated inside xsi/maya.
seqLookup = new Array;
seqLookup[10] = "010 - boy meets girl";
seqLookup[20] = "020 - boy loses girl";
seqLookup[30] = "030 - boy wins girl back";
// keep adding to define more sequences
function findItem(searchString) {
var result;
var curItem;
searchString = searchString.toLowerCase();
for (i = 1; i <= app.project.numItems; ++i) {
curItem = app.project.item(i);
if (curItem.name.toLowerCase().indexOf(searchString) != -1) {
result = curItem;
break;
}
}
return result;
}
// find the sequence name, in this case by looking for the first
// item in the 'sequence' folder of the project. this will need
// to change if run from a command line.
var seqFolder = findItem("sequence");
var seq = seqFolder.item(1).name.split(".")[0]
//now split into parts; it will be in the form seq_cam_shot_take_artist
var shotInfo = seq.split("_")
// find the slate comp, update the text fields
var slateComp = findItem("slate");
date = new Date();
date = date.getDay()+" - "+date.getMonth()+" - "+date.getFullYear();
slateComp.layer("scene").property("Source Text").setValue(seq);
slateComp.layer("cam").property("Source Text").setValue(shotInfo[1]);
slateComp.layer("seq").property("Source Text").setValue(seqLookup[parseInt(shotInfo[0],10)]);
slateComp.layer("date").property("Source Text").setValue(date);
