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

ExtendScript: Apply template not working?

Community Beginner ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

I am quite new to AE scripting though I have made a lot of ExtendScripts for Photoshop and Indesign. Now, I am trying to set up a workflow where I add a comp to the render queue and render it. As far as I understand, the only way to specify a Codec is by specifying a template. However, I only get an error that it's "not a valid template name". Just as a way to duoble check and eliminate any typos, I used the list of template names as an input but still get that very same error. Do anyone know if there is a way around this?

My example:

// add to render queue:
project.renderQueue.items.add(comp);
// getting an actual template name:
var template = project.renderQueue.item(1).outputModule(1).templates[10];
// trying to set the template
project.renderQueue.items.add(comp).applyTemplate(template);

 

TOPICS
Error or problem , Scripting

Views

861

Translate

Translate

Report

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

correct answers 1 Correct answer

Enthusiast , Jan 26, 2021 Jan 26, 2021

That last line looks wrong, trying to set the template at the same time you're adding the comp to the RQ. You seem to be confusing the two different uses of ApplyTemplate, one used directly on the RQItem object to set the render settings and one used on any OutputModule object to set the OM template.

 

Haven't tested this but try replacing the last line with:

alert(template); // just to make sure what you grabbed appears to be right
var theRender = project.renderQueue.items.add(comp);
theRender.out
...

Votes

Translate

Translate
LEGEND ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Start by actually not naming your variable "template". It's always bad practice to use words plainly that may be reserved keywords and could confuse the parser.

 

Mylenium

Votes

Translate

Translate

Report

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 Beginner ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Well thank you but I would appreciate if you actually tried to help me with the issue instead of nitpicking. The above is just an example and not code I intend to use. I get the same error when I use a string with the actual template name.

Votes

Translate

Translate

Report

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
Explorer ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

Really?  This was good advice, and snapping back at community members really is unlikeley to get you any meaningful discussion.  It doesn't take much to be nice.  I hope you sorted your issue.  It looks like Pauls answer is a good one.  I'm about to try it myself.

Votes

Translate

Translate

Report

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
Enthusiast ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

LATEST

In their defence, I'm not sure I'd term 'thank you but can you answer my actual question' as snapping back. Mylenium is a great contributor but his replies can sometimes come across as a bit brusque, which is probably why I jumped in with a more helpful answer.

It is decent advice though, I tend to use like 'theTemplate', 'theComp', etc when tempted to use variables that might otherwise be considered keywords.

Votes

Translate

Translate

Report

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
Enthusiast ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

That last line looks wrong, trying to set the template at the same time you're adding the comp to the RQ. You seem to be confusing the two different uses of ApplyTemplate, one used directly on the RQItem object to set the render settings and one used on any OutputModule object to set the OM template.

 

Haven't tested this but try replacing the last line with:

alert(template); // just to make sure what you grabbed appears to be right
var theRender = project.renderQueue.items.add(comp);
theRender.outputModule(1).applyTemplate(template);

 

 

 

 

Votes

Translate

Translate

Report

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 Beginner ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Yes, you are right thera are an error in that example. I have to add it before I get the template names though, since it won't be present otherwise. I will do some more testing.

Votes

Translate

Translate

Report

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 Beginner ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

That actually was it, it worked when I changed to:

var theRender = project.renderQueue.items.add(comp);//.applyTemplate(template);
var template = project.renderQueue.item(1).outputModule(1).templates[10];
theRender.outputModule(1).applyTemplate(template);

 

Thank you for the help! I believe the error message was the confusing part.

Votes

Translate

Translate

Report

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
Enthusiast ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Ah ok there are two errors then. You're adding the comp to RQ twice and trying to set an OutputModule template directly on a RQItem. You haven't said whether you're trying to set the render settings or output module so here's both. Delete as appropriate.

// add to render queue:
var theRender = project.renderQueue.items.add(comp);
// getting an actual template name:
var RQtemplate = theRender.templates[10];
var OMtemplate = theRender.outputModule(1).templates[10];
// trying to set the template
theRender.applyTemplate(RQtemplate);
theRender.outputModule(1).applyTemplate(OMtemplate);

 

 

Votes

Translate

Translate

Report

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
Enthusiast ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

You beat me to it. Glad you got it working!

Votes

Translate

Translate

Report

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