Skip to main content
Inspiring
June 5, 2024
Answered

set layer mode in multiple layers ?

  • June 5, 2024
  • 2 replies
  • 901 views

Hi,

 

How to adjust one layer settings for multiple compositions at the same time.

I have a layer that I use in several compositions. I would like to find a quicker way than go through all compositions to change the layer settings. Is there a script for this?

For example:

Can the layer setting "mode" be adjusted from "normal" to "color" in multiple compositions at the same time?

This would really help me.

Anybody have an idea?

 

Kind regards

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

Not knowing exactly what your spec is, here's an example that goes through all the comps looking for a layer with the same name as the selected layer and if it finds one, it sets the blend mode to "color".

function setLayerMode(){
	var comp = app.project.activeItem;
	if ( ! comp || ! (comp instanceof CompItem)){
		alert ("No comp active.");
		return;
	}
	if (comp.selectedLayers.length == 0){
		alert ("No layer selected");
	}
	var layer = comp.selectedLayers[0];
	for (var i = 1; i <= app.project.numItems; i++){
		if (app.project.item(i) instanceof CompItem){
			for (var j = 1; j <= app.project.item(i).numLayers; j++){
				if ((app.project.item(i).layer(j) instanceof AVLayer) && (app.project.item(i).layer(j).name == layer.name)){
					app.project.item(i).layer(j).blendingMode = BlendingMode.COLOR;
					break;
				}
			}
		}
	}
}
setLayerMode();

2 replies

Mathias Moehl
Community Expert
Community Expert
June 6, 2024

In my (paid) extension Automation Blocks, you can simply combine the block which loops over project items (like comps) with the block which sets attributes of layers. This example sets the bending mode of the layer with name "Black Solid" to "Multiply" for all comps, which are currently selected in the project panel:

 

The xml file of this block script is attached, such that you can directly load it into Automation Blocks.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
June 5, 2024

Not knowing exactly what your spec is, here's an example that goes through all the comps looking for a layer with the same name as the selected layer and if it finds one, it sets the blend mode to "color".

function setLayerMode(){
	var comp = app.project.activeItem;
	if ( ! comp || ! (comp instanceof CompItem)){
		alert ("No comp active.");
		return;
	}
	if (comp.selectedLayers.length == 0){
		alert ("No layer selected");
	}
	var layer = comp.selectedLayers[0];
	for (var i = 1; i <= app.project.numItems; i++){
		if (app.project.item(i) instanceof CompItem){
			for (var j = 1; j <= app.project.item(i).numLayers; j++){
				if ((app.project.item(i).layer(j) instanceof AVLayer) && (app.project.item(i).layer(j).name == layer.name)){
					app.project.item(i).layer(j).blendingMode = BlendingMode.COLOR;
					break;
				}
			}
		}
	}
}
setLayerMode();
Inspiring
June 7, 2024

Hi Dan, thank you for the script, it works. It seems the adjustment is need for only a couple of my comps per project. Any idea if this script can be adjusted to run for a list of comp names?

Dan Ebberts
Community Expert
Community Expert
June 7, 2024

This variation has an array of comp names at the top, the script will only check comps that are in the list..

function setLayerMode(){

	var compNames = ["Comp 1", "Comp 2"];

	var comp = app.project.activeItem;
	if ( ! comp || ! (comp instanceof CompItem)){
		alert ("No comp active.");
		return;
	}
	if (comp.selectedLayers.length == 0){
		alert ("No layer selected");
	}
	var layer = comp.selectedLayers[0];
	for (var i = 1; i <= app.project.numItems; i++){
		if (app.project.item(i) instanceof CompItem){
			var gotOne = false;
			for (var j = 0; j < compNames.length; j++){
				if (app.project.item(i).name == compNames[j]){
					gotOne = true;
					break;
				}
			}
			if (! gotOne) continue;
			for (var j = 1; j <= app.project.item(i).numLayers; j++){
				if ((app.project.item(i).layer(j) instanceof AVLayer) && (app.project.item(i).layer(j).name == layer.name)){
					app.project.item(i).layer(j).blendingMode = BlendingMode.COLOR;
					break;
				}
			}
		}
	}
}
setLayerMode();