A. Nance
A. Nance

Reputation: 21

Running Post-BatchRender MEL Command

I'm looking for a way to run a MEL script at the conclusion of a batch render. Is this possible? I'm aware of the 'Pre render MEL' and 'Post render MEL' render options, but am looking to run a script at the conclusion of a batch render.

This code specifically fires as expected following 'Render View' initiated renders but fails to fire following any type of batch render:

setAttr -type "string" defaultRenderGlobals.postMel     "promptDialog -message \"done: postMel\"";  
setAttr -type "string" defaultRenderGlobals.postRenderMel   "promptDialog -message \"done: postRenderMel\""; 

Is there perhaps a buried setting that suppresses these callbacks for batch renders?

System Info
Maya Ver: 2009 x64
OS: Win 8.1

Upvotes: 2

Views: 2049

Answers (3)

skar
skar

Reputation: 401

Please correct me if I am wrong. Are you launching the batch render from the UI session of Maya and want a mel to get executed in the UI session once the batch render finishes?

The postRenderMel code will work only in the batch session and will not connect back to the UI session of Maya. The only connection Maya Ui session makes to the Maya batch is the Stdout. So if you want a mail sent on finishing the render that is totally possible. But if Maya UI session needs to load a UI that will not work with a postRenderMel.

I tried searching but I could find any event associated with batch render completion. The way I would probably try would be to wrap the batch render with custom code may be using Python Subprocess and call the Maya batch to render followed by the command that's needs to execute on completion.

You can do this in a separate thread that way it doesn't block the current Maya session.

Upvotes: 0

joojaa
joojaa

Reputation: 4434

The reason this does not work is not so much the event but rather what you do. The code:

promptDialog -message "done: postMel"

Will not work in batch render! This is because batch mode is a separate process (separate program running in parallel to Maya). The batch mode has no GUI so it does not have any way to react to GUI calls.

So you must do something else.

Upvotes: 0

mhlester
mhlester

Reputation: 23251

There are several different Pre/Post MEL options:

  • Pre render MEL (preMel):
    This is run before the first frame renders
  • Post render MEL (postMel):
    This is run after the last frame renders
  • Pre render layer MEL (preRenderLayerMel):
    This is run before starting the first frame of a batch in a certain render layer
  • Post render layer MEL (postRenderLayerMel):
    This is run after the last frame of a batch in a certain render layer, before switching to the next layer
  • Pre render frame MEL (preRenderMel):
    Originally these were the only two options. This runs before every single frame of rendering
  • Post render frame MEL (postRenderMel): Originally these were the only two options. This runs after every single frame of rendering

These do run in batch. In our pipeline they provide a callback to verify and update values at the beginning (preMel), update our render queue system with progress (preRenderMel and postRenderMel), and final reports at the end (postMel).

Upvotes: 1

Related Questions