PDA

View Full Version : Mayabatch and Pre Render Mel


DigitalCrystal
05-06-2009, 05:27 AM
Has anyone had trouble with Mayabatch when running a "Pre Render Mel" script from the render settings?


With the help from a few talented co-workers, I've created a set of scripts in python that update a gui to record and estimate frame/batch elapse times and estimated times... unfortunately, the scripts cause mayabatch to fail... well more accurately: I click "batch render" and after about 20 seconds the script editor states "Render Complete" even though it hasn't rendered a frame.

The scripts work when rendering a single frame through the renderView, but that's not what this script was created for!

Any ideas here?:shrug:

DigitalCrystal
05-07-2009, 09:59 PM
...I've been doing some research, I checked out my mayarender.log and it states:

Error: name 'preRender' is not defined
# Traceback (most recent call last):
# File "<maya console>", line 1, in
# NameError: name 'preRender' is not defined

The scripts work, as mentioned above, in maya during a single frame render. So this seems to show that the script can't be found outside of maya. Makes sense really...

So, I did some more research and found this in the maya help docs:


In addition to supporting Python within the Maya application, Maya also supports using the Python modules of Maya from a standalone Python interpreter. This is useful when doing batch processing, or when accessing the functionality of Maya from another application that uses Python (such as MotionBuilder or Toxik).

We provide a standalone Python interpreter which is configured correctly for importing Maya functionality.

* On Windows and Linux, run the mayapy executable from the bin directory of Maya.
* On Mac OS X, run the mayapy executable from
../ Maya.app/Contents/bin.

Once the Python interpreter is loaded, Maya must be loaded and initialized. To do so, type the following in the window:

import maya.standalone
maya.standalone.initialize( name='python' )

Seems like the direction I need to take.. the purpose of this script is to update a GUI though, so I will probably be looking into PyQt and tkinter since it seems like it will be supported in the future. Anyone have any experience with this?

haggi
05-08-2009, 09:51 PM
I'd try this one in the preRenderMel:

python("youpythonscripthere");

e.g.
python("from mymodules import updateGUI; updateGUI()");

DigitalCrystal
05-12-2009, 12:24 AM
I'd try this one in the preRenderMel:

python("youpythonscripthere");

e.g.
python("from mymodules import updateGUI; updateGUI()");

Thanks for the response haggi.

I have been importing my scripts using a seperate script.

I have called my functions using:

python("preRender.PRexec()");

This works during a single frame render--when it comes to batch rendering, the computer seems to lose track of the loaded script and gives the error listed in my last post.

I haven't tried loading the script as you mentioned though:
python("from mymodules import updateGUI; updateGUI()");

It does seem like it's similar in nature. By the looks of it, mayabatch cannot find preRender even after it's been loaded.

Based on the findings over the last few days, it seems like the best approach will be to create a separate program that will load the gui outside of maya to accomplish this task. Rather than relying on the preRenderMel and postFrameRenderMel, I believe parsing the mayarender.log file will be a better approach. Has anyone had any experience doing this? This seems to be much more involved than I had originally intended...or is it? ;)

haggi
05-12-2009, 09:26 PM
Well, we use pre and post render mel scripts in our production pipeline, and they work really great. So I'd say it would be more efficient to check where your error lies instead of writing a parser.

How do you start your batch rendering? It seems that your module is not loaded at all in the batch.

Did you check if your modules are really loaded in batch? When do you load them, in the userSetup.py?

DigitalCrystal
05-13-2009, 05:33 AM
Well, we use pre and post render mel scripts in our production pipeline, and they work really great. So I'd say it would be more efficient to check where your error lies instead of writing a parser.

How do you start your batch rendering? It seems that your module is not loaded at all in the batch.

Did you check if your modules are really loaded in batch? When do you load them, in the userSetup.py?

Very interesting information here. To answer your questions, I'm the standard "Render>Batch Render" command within the UI at the moment. I have not tried CMD batching.

To import the scripts when I open a file, I run a maya mel script that I have linked to a shelf icon. Here's a look at the code for this:

python("import preRender");
python("import JH_rStats");
python("import postFrameRender");
setAttr -type "string" defaultRenderGlobals.preMel "python(\"preRender.PRexec()\");";

So, as you mentioned, the scripts don't appear to be loading in the batch. I had not looked into the userSetup.py. I suppose the better question is, how are you loading your scripts into your batch? :thumbsup:

Thanks for your help!

CGTalk Moderation
05-13-2009, 05:33 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.