Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Contributor ,
Nov 02, 2022 Nov 02, 2022

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
TOPICS
How to , Scripting
886
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2022 Nov 02, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 02, 2022 Nov 02, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 02, 2022 Nov 02, 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 & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 02, 2022 Nov 02, 2022

Not in this case, unless I am misunderstanding you.  When I do it manually, AE puts it on top (by default) which is exactly what I need.  So if there were just some way to say to AE ... "Hey, take THIS comp at insert into all of THESE comps," all would be good.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 02, 2022 Nov 02, 2022

Perfect job for Automation Blocks:

Screenshot 2022-11-02 at 20.48.jpgexpand image

 

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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 02, 2022 Nov 02, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 02, 2022 Nov 02, 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()
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 02, 2022 Nov 02, 2022

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 02, 2022 Nov 02, 2022

Hmmm, the script runs fine, but "OK" dialogue box is preventing me from selecting the comps (or anything else for that matter.)  i.e. The pop window prevents you from interacting with AE.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 02, 2022 Nov 02, 2022

That's interesting. I was surprised that it worked in the version of AE that I'm running, but it definitely doesn't work in older versions. Try this one. First select the desination comps, then launch the script. The script will then ask for the name of the source comp.

function addCompToOtherComps(){
	var mySelected = app.project.selection;
	var compName = prompt ("Enter name of source comp.","");
	if (compName == null){
		alert ("No comp name entered.");
		return;
	}
	var sourceComp = null;
	for (var i = 1; i <= app.project.numItems; i++){
		if (app.project.item(i) instanceof CompItem && app.project.item(i).name == compName){
			sourceComp = app.project.item(i);
			break;
		}
	}
	if (sourceComp == null){
		alert ("Comp named '" + compName + "' not found.");
		return;
	}
	var destinationComps = [];
	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()
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 02, 2022 Nov 02, 2022
LATEST

Wow, thanks Dan!  I'm doing a batch of renders now, but will give it shot when it finishes up and let you know.  Thanks again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2022 Nov 02, 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 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines