Is there a way (script) to automate the process of adding a comp to a bunch of comps?
Copy link to clipboard
Copied
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.
- Select the comp that is going into other comps
- 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.)
- Repeat 1,000 times. 🙂
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Perfect job for Automation Blocks:
I attached the Automation Blocks script to this post, such that you can directy load it into Automation Blocks.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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()
Copy link to clipboard
Copied
Thanks, Dan ... you are the man, I'll give it a shot!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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()
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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

