Skip to main content
Known Participant
November 2, 2022
Question

Is there a way (script) to automate the process of adding a comp to a bunch of comps?

  • November 2, 2022
  • 4 replies
  • 1186 views

Hi.  Is there an existing script that would allow me to take a single composition and place it into multiple compositions all at once?  In other words, I want to select a comp and place it into a selection of other comps, with that comp being on top.

 
I can do that now manually, but I have to do it for close to 1,000 comps and was hoping there was an automated way to do this, as currently I have to:
 
  1. Select the comp that is going into other comps
  2. Drag that comp onto EACH of the target comps one-by-one.  (Fortunately, it DOES automatically put it in as the top-most layer in the stack.)
  3. Repeat 1,000 times. 🙂
 
Thanks,
Tim
This topic has been closed for replies.

4 replies

Mylenium
Legend
November 2, 2022

I think Dan's code needs some explicit UI, not just the automated alert() so AE doesn't return to the UI and forgets the script...

 

Mylenium 

Dan Ebberts
Community Expert
Community Expert
November 2, 2022

That would be a pretty simple script. Here's an attempt at it. Select your source comp, run the script, select the destination comps, and click OK in the dialog.

function addCompToOtherComps(){
	var mySelected = app.project.selection;
	if (mySelected.length != 1 || ! (mySelected[0] instanceof CompItem)){
		alert ("Select single source comp in Project panel.");
		return;
	}else{
		var sourceComp = mySelected[0];
	}
	alert ("Select destination comps and click 'OK'");
	var destinationComps = [];
	mySelected = app.project.selection;
	for (var i = 0; i < mySelected.length; i++){
		if (mySelected[i] instanceof CompItem && mySelected[i].id != sourceComp.id){
			destinationComps.push(mySelected[i]);
		}
	}
	if (destinationComps.length == 0){
		alert ("No usable destination comps selected.");
		return;
	}
	for (var i = 0; i < destinationComps.length; i++){
		destinationComps[i].layers.add(sourceComp);
		destinationComps[i].layer(1).startTime = 0;
	}
}
addCompToOtherComps()
Known Participant
November 2, 2022

Thanks, Dan ... you are the man, I'll give it a shot!

Mathias Moehl
Community Expert
Community Expert
November 2, 2022

Perfect job for Automation Blocks:

 

I attached the Automation Blocks script to this post, such that you can directy load it into Automation Blocks.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Known Participant
November 2, 2022

Thank you also, Mathias.  Unfortunately I am still rocking CS6, so it's a no-go for me.  Appreciate it though, and will definitely take another look at AB if/when I re-subscribe to CC.

Mylenium
Legend
November 2, 2022

I don't know any existing script, but your request sounds simple enough. You'd simply use the respective .add() methods to fire your pre-comp at the selected other comps. The only added difficulty is that you would need to include a check that the first comp you select is the one you add or you create a dialog to pick one or use special naming conventions. If you study a script liek the default comp changer that comes with AE (or any other comp-realted script you can find) you could possibly figure it out.

 

Mylenium

Known Participant
November 2, 2022

Wow, hard to believe with the MASSIVE amount of scripts -- some of them incredibly complex -- that there isn't already something to do, what is essentially a relatively simple thing.  Unfortunately, my scripting skills are beyond sub-par, so it would take me longer to figure it out than to drag-n-drop the 1,000 instances.

Roland Kahlenberg
Legend
November 2, 2022

Agreed on the number of scripts available but disagree that this is simple. You forget that when placing a new asset into the Timeline, it's stacking order in the Timeline is critical and it is this that makes it difficult.

 

 

Very Advanced After Effects Training | Adaptive &amp; Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV