Skip to main content
Participant
March 25, 2024
Answered

Set up continuity, motion blur to all layers in current comp

  • March 25, 2024
  • 1 reply
  • 652 views

Hello guys!

Thank you for your attention to this post. I am new to scripting in AE, but I would be really thankful if you help me with one script.

The issue is that I am working with many layers and comps and it takes a bit time to select all layers in current comp and turn on continuity, motion blur on all layers and lock and turn on multiply mode only first layer. These are steps for all comps and script would save so much time for me...

I've included 2 screens before and after I do these steps manually.

This topic has been closed for replies.
Correct answer Dan Ebberts

Just change that line to:

if (i == comp.numLayers){

This is a slightly better version that won't break if you run it twice:

function processLayers(){
	app.beginUndoGroup("Process Layers");
	var comp = app.project.activeItem;
	if ((! comp) || ! (comp instanceof CompItem)){
		alert ("Please select a comp.");
		return;
	}
	for (var i = 1; i <= comp.numLayers; i++){
		var layer = comp.layer(i);
		if (layer instanceof AVLayer){
			layer.locked = false;
			layer.motionBlur = true;
			if (layer.canSetCollapseTransformation){
				layer.collapseTransformation = true;
			}
			if (i == comp.numLayers){
				layer.blendingMode = BlendingMode.MULTIPLY;
				layer.locked = true;
			}
		}
	}
	comp.motionBlur = true;
	app.endUndoGroup();
}
processLayers();

1 reply

Dan Ebberts
Community Expert
Community Expert
March 25, 2024

I think this does what you want:

function processLayers(){
	app.beginUndoGroup("Process Layers");
	var comp = app.project.activeItem;
	if ((! comp) || ! (comp instanceof CompItem)){
		alert ("Please select a comp.");
		return;
	}
	for (var i = 1; i <= comp.numLayers; i++){
		var layer = comp.layer(i);
		if (layer instanceof AVLayer){
			layer.motionBlur = true;
			if (layer.canSetCollapseTransformation){
				layer.collapseTransformation = true;
			}
			if (i ==1){
				layer.blendingMode = BlendingMode.MULTIPLY;
				layer.locked = true;
			}
		}
	}
	comp.motionBlur = true;
	
	app.endUndoGroup();
			
}
processLayers();

except that in your description you say to lock and turn on multiply mode for the first layer, but in your image you show that for the last layer, which is named "Layer 1", so you may have to change this line:

if (i ==1){

to something like this:

if (layer.name == "Layer 1"){

 

RamikksAuthor
Participant
March 25, 2024

Jesus Christ, its almost EXCACTLY what I needed!! But yeah, you're right. I meant first layer from the bottom. So every time I use your script, the first layer on the bottom would always lock and multiply. 

I think I can use with the layer.name == "Layer 1" with no issues anyway. Thank you! But if the layer is not called Layer 1, is there a way to lock and multiply first bottom layer?

Dan Ebberts
Community Expert
Community Expert
March 25, 2024

Just change that line to:

if (i == comp.numLayers){