Bypassing layer's frameBlending read-only limitation
Posted: June 19th, 2009, 1:04 pm
For some reasons the frameBlending attribute of an AVLayer is read-only, meaning that you cannot (via a script) set it to the type you want. I was working on a project in which most of the comps contained tons of layers (imported from a Premiere project). Some of these layers were time stretched and I wanted to set the frame blending type to Pixel Motion for these layers only.
Again the handy executeCommand function came to the rescue :
Again the handy executeCommand function came to the rescue :
Code: Select all
var comp = app.project.activeItem;
var cmd = "Pixel Motion";
app.beginUndoGroup("FrameBlending.jsx");
if (comp instanceof CompItem)
{
// deselect all
while (comp.selectedLayers.length) comp.selectedLayers[0].selected = false;
// loop through each layer
for (var i = 1; i <= comp.numLayers; i++)
{
var layer = comp.layer(i);
// select current layer
layer.selected = true;
// set frame blending type to pixel motion
// when time stretch factor has been modified
if (layer.stretch != 100)
{
app.executeCommand(app.findMenuCommandId(cmd));
}
// deselect current layer
layer.selected = false;
}
// activate frame blending switch for the comp
comp.frameBlending = true;
}
app.endUndoGroup();