Hello,
I am using the MayaBatch/Mentalray plugin for Deadline to render some 3-D layers. I have come across some cases where the properties of the Maya scene file must be modified just before render time - for example, hiding certain layers, adding some primitive objects, and so on. Typically I use something like PyMEL to handle tasks like these, is there a way to implement something like this in the Deadline render workflow?
From the documentation, we can set a script option “PreJobScript” in our info file:
PreJobScript= : Specifies a full path to a python script to execute when the job initially starts rendering (default = blank).
I have looked at some of the python scripts that ship with the Deadline 6 distribution, however these seem more geared towards general administrative tasks.
Thanks lots!
Parmjit V.
Software Developer
Hi Parmjit,
These pre/post job and task scripts are just general purpose scripts that run completely separate from the actual rendering process. If I understand correctly (based on this other thread: viewtopic.php?f=156&t=9396), you’re wanting scripts to modify the scene file as part of the rendering process, correct?
Maya’s Render.exe executable has flags for pre/post scripts:
Mel callbacks
-preRender string Mel code executed before rendering
-postRender string Mel code executed after rendering
-preLayer string Mel code executed before each render layer
-postLayer string Mel code executed after each render layer
-preFrame string Mel code executed before each frame
-postFrame string Mel code executed after each frame
These can be used in the MayaCmd plugin by adding them as additional command line arguments. For MayaBatch, we could probably expose these options as well. If this would suit your needs, let us know and we’ll look into it.
Cheers,
Just to confirm, will exposing these script options allow you to do what you need to do? Just want to make sure that’s the case before we look into supporting this.
Thanks!
Hi Ryan,
Sorry for the delay in getting back to you. I don’t believe any further action is needed on your end regarding this issue, however if I do require that these script options be exposed, I can request this be done in a new post. Is that OK?
Parmjit
Hey Ryan,
I started helping with this today too, and it turns out that we will need functionality to add arguments (or to be specific, the -script argument) to the MayaBatch renderer. Since we’re pressed for time, we hard coded what we need into the MayaBatch.py plugin file for now, and that’ll meet our immediate needs. Here’s an example of what’s working for us, starting at line 1270 in MayaBatch.py:
def RenderArgument( self ):
renderArguments = "-prompt -file \"" + self.SceneFile + "\"" + " -script \"" + "C:\path\to\script.mel" + "\""
renderArguments += StringUtils.BlankIfEitherIsBlank( " -proj \"", StringUtils.BlankIfEitherIsBlank( self.ProjectPath, "\"" ) )
return renderArguments
If you’re able to incorporate that functionality into deadline properly, we could revert the plugin script and do it up the proper way. Until then, this workaround should meet our needs.
Thanks.
Darren
Hey Darren,
We won’t have time to do this for 6.0, but I’ve put it on the wishlist targeting 6.1. Glad to hear you have it working the way you need to for now!
Cheers,
Ok, that’s no problem - we’ll be fine with our manually edited plugin script in the meantime.
On a related note, is there any built-in way to run a command on the slave before maya is launched? I’ve got an app that syncs plugins and scripts, and I’d like to hook it in so it runs before deadline starts maya (much like the old PF way, but without acting as a launcher as well). I’m sure it wouldn’t be hard for me to add this to the MayaBatch.py script if you don’t have this functionality at the moment, but I thought I’d ask if there’s a proper way first.
Thanks.
Darren
Hey Darren,
You can create a script in the MayaBatch folder called JobPreLoad.py. This script will get executed before each job is loaded, so it can do the syncing for your. This script needs to have a main function, and this function is passed a single parameter, which is the current DeadlinePlugin instance. Here’s a quick example script:
def __main__( deadlinePlugin ):
deadlinePlugin.LogInfo( "This is a job preload script!" )
You can find the API reference for the DeadlinePlugin class in the Scripting Reference that can be downloaded here:
viewtopic.php?f=85&t=9482
Cheers,
Fantastic - looks like that should do exactly what I need. I’ll dig into that today and check back if I have any questions. Thanks!