Adding additional output modules...

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
User avatar
vfxman
Posts: 49
Joined: February 23rd, 2007, 7:00 pm
Location: California
Contact:

Adding additional output modules without using

Code: Select all

executeCommand(app.findMenuCommandId("Add Output Module"));
I am able to access OM 2 and change it like this...

Code: Select all

curItem.outputModule(2).applyTemplate(templateName);
...but obviously only when OM index 2 exists to begin with. I was trying to add a second OM via:

Code: Select all

OMCollection.add()
but I'm not figuring out the syntax for that. Is that even possible? Would I need to loop through the OM's first?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Here's an example that should help:

Code: Select all

{	
	var activeItem = app.project.activeItem;
	
	// make sure a comp is selected
	if (activeItem != null && activeItem instanceof CompItem) {

		// if there is one, grab the first existing render queue item
		if (app.project.renderQueue.numItems != 0) {
			var RQitem = app.project.renderQueue.item(1);
			
		} else {
			// othewise create a new one from the selected comp
			var RQitem = app.project.renderQueue.items.add(activeItem);
		}
		// grab the first output module
		var OMitem1 = RQitem.outputModules[1];
		
		// if there is only one output module, add another one
		if (RQitem.outputModules.length > 1) {
			var OMitem2 = RQitem.outputModules[2];
		} else {
			var OMitem2 = RQitem.outputModules.add();
		}
		
		// apply templates
		RQitem.applyTemplate("Draft Settings");
		OMitem1.applyTemplate("Photoshop");			
		OMitem2.applyTemplate("Alpha Only");
	}
}
User avatar
vfxman
Posts: 49
Joined: February 23rd, 2007, 7:00 pm
Location: California
Contact:

Thanks Paul, works great. I modified it a little more so it loops through all items in render queue and changes them, which is what I will end up needing for a project next week. As always I appreciate the help.

Here's the new code:

Code: Select all

{
	var activeItem = app.project.activeItem;

	// make sure a comp is selected
	if (activeItem != null && activeItem instanceof CompItem) {

		// if there is one, grab the first existing render queue item
		if (app.project.renderQueue.numItems != 0) {

		var existingRQ = app.project.renderQueue.numItems;
		
		for (a = 1; a <= existingRQ; a++) {
		var curItem = app.project.renderQueue.item(a);
		if (curItem.status == RQItemStatus.QUEUED) {
		// if there is only one output module, add another one
		if (curItem.outputModules.length > 1) {
		var OMitem2 = curItem.outputModules[2];
		} else {
		var OMitem2 = curItem.outputModules.add();
		}

		var OMitem1 = curItem.outputModules[1];
		// apply templates
		curItem.applyTemplate("Best Settings");
		OMitem1.applyTemplate("RGB");
		OMitem2.applyTemplate("Alpha Only");
		}
		}
		}
	}
	}
Post Reply