Skip to main content
Inspiring
October 2, 2020
Answered

How do I add multiple selected comps to the render queue via Extend Script?

  • October 2, 2020
  • 1 reply
  • 1578 views

I have an ScriptUI button that adds a single selected comp to the render queue and applies an Output module and Render module…

 

var comp = app.project.activeItem;
var item = app.project.renderQueue.items.add(comp);
var outputModule = item.outputModule(1);
outputModule.applyTemplate("Multi-Machine Sequence TIFF 8 Bit RGB");
item.applyTemplate("Multi-Machine Settings");

 

 

However I need to make it work for multiple selected comps.

 

I tried a modified version using app.executeCommand(2161); which is the Command ID for 'Add to Render Queue' but that feels like cheating haha. In any case, it doesn't quite work. It adds multiple comps, but it doesn't change the Output module. Maybe my variable syntax is wrong…

 

app.executeCommand(2161);
var item = app.project.renderQueue.items;
outputModule.applyTemplate("Multi-Machine Sequence TIFF 8 Bit RGB");
item.applyTemplate("Multi-Machine Settings");

 

 
Is there a way to do this using my original method which doesn't use a command ID? Or if not, is there a way to get my command ID version working?
This topic has been closed for replies.
Correct answer Dan Ebberts

Oops. I left off the first line.

 

var myItems = app.project.selection;
var comp, item, outputModule;
for (var i = 0; i < myItems.length; i ++){
  if (! (myItems[i] instanceof CompItem)) continue;
  comp = myItems[i];
  item = app.project.renderQueue.items.add(comp);
  outputModule = item.outputModule(1);
  outputModule.applyTemplate("Multi-Machine Sequence TIFF 8 Bit RGB");
  item.applyTemplate("Multi-Machine Settings");
}

1 reply

Dan Ebberts
Community Expert
Community Expert
October 2, 2020

If you have the comps selected in the project panel, something like this should work (not tested though):

 

var comp, item, outputModule;
for (var i = 0; i < myItems.length; i ++){
  if (! (myItems[i] instanceof CompItem)) continue;
  comp = myItems[i];
  item = app.project.renderQueue.items.add(comp);
  outputModule = item.outputModule(1);
  outputModule.applyTemplate("Multi-Machine Sequence TIFF 8 Bit RGB");
  item.applyTemplate("Multi-Machine Settings");
}
Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
October 2, 2020

Oops. I left off the first line.

 

var myItems = app.project.selection;
var comp, item, outputModule;
for (var i = 0; i < myItems.length; i ++){
  if (! (myItems[i] instanceof CompItem)) continue;
  comp = myItems[i];
  item = app.project.renderQueue.items.add(comp);
  outputModule = item.outputModule(1);
  outputModule.applyTemplate("Multi-Machine Sequence TIFF 8 Bit RGB");
  item.applyTemplate("Multi-Machine Settings");
}
Inspiring
October 2, 2020

Worked like a charm. Thanks Dan!