-
How to Change a Precomp's Setting with ExtendScript
Is there a way to change a precomp’s setting and the layers inside it while inside the master comp? It seems accessing the precomp’s height for example is “read-only”. How can I “enter” the precomp, change the settings, and then go back to the main comp? Any suggestions would be most appreciated.
// convert each layer into a precomp
var parentComp = app.project.activeItem;
var selected = parentComp.selectedLayers;
for (var i = 0; i < selected.length; i++) {
processLayer(parentComp, selected[i]);
}
function processLayer(parentComp, layer) {
var layerIndex = layer.index;
var layerIndices = new Array(1);
layerIndices[0] = layerIndex;
parentComp.layers.precompose(layerIndices, layer.name, true); // (moveAllAttributes = true);
// *this is the part that doesn’t work because properties of “precomp” are read-only
var precomp = parentComp.layer(layerIndex);
adjustComp(precomp);} function adjustComp(comp) {
// adjust height, width, and trim to layer(1)’s outPoint
}
A possible alternative solution would be to create a comp, add the layer that needs to be in the comp, then delete the original layer, but I’d like to know if it’s possible just to change the precomp’s settings directly. More info in case what I’m doing doesn’t make sense: I have a comp with hundreds of video files that have been synced to audio in Premiere. It’s a virtual choir with different singers coming in at different times. Each layer needs to be processed and rendered out as an individual image sequence, and the start time of each layer needs to be preserved. The first n number of frames of some singers will be black before the singer starts, which is fine.
Update: I solved it. See below.