2

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

A. Nance
  • 21
  • 5
  • Could you explain the difference you're hoping to achieve between what you want and the Post render MEL option? – mhlester Apr 16 '15 at 20:50
  • I've written a a script that generates thumbnails for batch renders and creates a JSON log file that can be easily parsed into a conveniently viewed html file. I would like to be able to verify that that batch render succeeded. To do this I would prefer to be able to run a proc at the conclusion of the batch render. It is my understanding that that Pre-/Post- render option commands do not pertain to batch rendering and perhaps more importantly that they are applied before/after each frame is rendered. I only want to run a MEL proc as a callback from the batch render, if possible. – A. Nance Apr 17 '15 at 01:52
  • Sorry about that. I would say feel free to return the favor but I don't seem to get notifications of any sort from stackoverflow. At any rate I've added script to my original question that, at least on my machine running Maya 2009, seems to contradict your assertion. – A. Nance Apr 17 '15 at 20:33
  • To your edit, a `promptDialog` won't run in batch because batch doesn't have a gui. You'll have to settle with other methods of alerting the user. – mhlester Apr 17 '15 at 20:34

3 Answers3

1

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).

mhlester
  • 22,781
  • 10
  • 52
  • 75
  • I appreciate your help but this still doesn't work for me. Maya doesn't fire any of the scripts (pre- or post-) when I run batch renders. At this point I suspect that either I'm missing a buried config setting or there is handled error in the batch renderer resulting in these callbacks getting skipped. – A. Nance Apr 20 '15 at 19:04
0

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.

joojaa
  • 4,354
  • 1
  • 27
  • 45
  • mhlester pointed this out last week and to be clear I'm not trying to get the batch render to do anything I'm trying to get Maya to do something in response to the batch render finishing. What exactly should I be able to do with these pre- post- MEL scripts with respect to batch renders initiated from within Maya's GUI? – A. Nance Apr 23 '15 at 22:26
  • @ANance There is no such mechanism. however if you do this via a python system call on a thread then you should be able to message on join. – joojaa Apr 24 '15 at 04:20
0

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.

skar
  • 401
  • 5
  • 15