Bypassing layer's frameBlending read-only limitation

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

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 8) :

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();
Post Reply