Hello!
I want to write a postjob script which does following:
after job rendered, requeue job with another camera.
requeueing job works:
args = StringCollection()
args.Add( "RequeueJob" )
args.Add( SlaveUtils.GetCurrentJobValue( 'JobId')) #job.JobId ) # in 5.1
ClientUtils.ExecuteCommand( args )
and using SlaveUtils i can take plugin value for ‘Camera’.
But how can i change it? Cause the changing settings are in JobUtils which are for monitor selected tasks. ‘SetJobSetting’ in command line utils also doesn’t work… So, how can i change the camera?
(and, bytheway, can i easily find out, how many cameras there are in my scene?)
ps. 3dsmax job
Which version of Deadline are you using? I think this is definitely doable in Dealine 6. It’s probably also possible with Deadline 5, but it will likely require a little more effort.
Cheers,
Hi Ryan,
thanks for the reply, i’m using Deadline 5!
Thanks! Here’s an example of a script that should do the trick:
from System.IO import *
from System.Collections import *
from System.Collections.Specialized import *
from Deadline.Scripting import *
import traceback
def __main__():
jobId = SlaveUtils.GetCurrentJobValue( 'JobId' )
jobDirectory = Path.Combine( GetJobsDirectory(), jobId )
localPluginInfoFilename = GetPluginInfoFilename()
repoPluginInfoFilename = Path.Combine( jobDirectory, Path.GetFileName(localPluginInfoFilename) )
newLines = []
lines = File.ReadAllLines(repoPluginInfoFilename)
for line in lines:
if not line.startswith( "Camera=" ):
newLines.append(line)
newLines.append("Camera=Testing")
File.WriteAllLines(repoPluginInfoFilename, tuple(newLines))
args = StringCollection()
args.Add( "RequeueJob" )
args.Add( jobId )
ClientUtils.ExecuteCommand( args )
What we’re doing is figuring out the path to the job’s plugin info file in the repository. This file contains the camera that will be rendered. If you want to take a look at the contents of this file, right-click on your max job in the Monitor and select Explore Repository Directory. Typically, the Max job’s plugin info file is called max_job_info.job or max_plugin_info.job. The file just contains a bunch of key=value pairs. You should see the Camera= option, and you should also see options like Camera0=, Camera1=, etc, which will contain all the cameras in the scene.
In our script, we’re just skipping over the existing Camera= line in the file, and adding our own at the end. In this case, the “Testing” camera will be rendered for the job.
Hope this helps!
Thank you very much, Ryan!
Yes, there was a thought to change the file itself, but i thought it is the last thing to do) You say, in Deadline 6 it can be done without brute-force ? 
Yeah, in Deadline 6, those plugin info settings are stored in the job object itself, so you can just change it in the job object and then save it before requeuing it.
that’s cool, thanks again! 
Sorry again, but how can i then change the outputfilename for a render elements? =)
The main render output is stored in plugin info filename, but render elements are in jobId.job. When i try to change the paths there, it doesn’t work. So is there any method to fix the output path for a new camera render elements, or it should be done somehow using maxscript preopen callback?
Hmm, I don’t think this is possible at the moment. The paths in the job file are just there to tell Deadline where the output is going - they’re not used by 3dsmax during rendering. That’s why changing them doesn’t make a difference. Since the element paths aren’t stored in the plugin info file, that means that 3dsmax is using whatever is in the scene file at the time of submission, and there currently isn’t any way to workaround that.
We can log it as a feature request to see if we can store those paths in the plugin info file.
Cheers,
Thanks, Ryan!
So, i think i can put a maxscript on filePostOpen callback or smth like that. The only thing to undestand - when do the changes in .job file make affect on a .max file? So, i change a camera or a main render path in the job file, so where should i put a callback in max to compare the camera and the render elements output paths? postOpen, preRender…?
Ah, didn’t even think about a maxscript callback. I think the preRender option would be the best, and it should work. This ensures that the path gets updated before each render.
The postOpen option would probably work too, but it would only get called for the first frame the machine renders because it keeps the scene loaded in memory between frames.
Hi, Ryan!
I’m sorry, but can you try to change path using callback? 
For me it also doesn’t works. I tried all prerender callbacks and postOpen - the path to render elements is changed (i look into .max file in the repository), but it actually renders to the old path…
If it is so, this feature would be very useful in the next versions, cause we need to send many cameras (50 for example) by time, and don’t want to have 50 jobs and 50* time to submit each job to deadline…
We still have it logged as a request. We’re pretty tapped for 6.1 dev at the moment though, but hopefully we can get it into the 6.x release cycle (assuming it’s something we CAN do).
There’s always the option of our professional services model where we do custom development for a fee, which might be an option for you if you need this functionality immediately. You can always contact sales@thinkboxsoftware.com if that’s something you want more information about.
Cheers,