AWS Thinkbox Discussion Forums

3DS Max - Maxscript - which slave has been assigned to a job?

Hi all,
Would it be possible to extract some information about a submitted job, it’s ID or a slave name that it has been assigned to after the submission? Extract it to a text file or preferably keep it within the maxscript?

Also, is there a quick way to ‘submit’ the job (aka "press the button…) after a line like this:
macros.run “Deadline” “SubmitMaxToDeadline”
? In other words, how to automatically submit the job after running the Deadline Submitter?

Sorry if these questions have been raised on the forum before but so far I couldn’t find anything useful. I’m happy if anyone could point me out the right piece of documentation.

Cheers!

Well, no one assigns a Slave to a job specifically. They’re free to take the jobs they want, they’re just really well behaved about it. :smiley:

I think your best bet is to get the job id. I know that we call deadlinecommandbg to do the submission itself, and the id is returned there. I spent some time reading over the Deadline docs, but what I found (waitForCommandToComplete()) doesn’t seem to support returning the textual output of Deadline Command. I would think we have that information within the MaxScript, so I’ll let Mike or Bobo comment here.

The Job ID is part of the message that DeadlineCommand outputs after the submission finishes. In the Max Submitter (SMTD), we call DeadlineCommandBG (the background process without a visible console window), and it writes two text files to disk - one with the return value, and one with the report. In SMTD, we have a function that gets the message from the second text file, and also parses it to extract the JobID that was produced.

You can look at the MAXScript Submission tutorial on the Deadline website for the simplest code possible:
deadline.thinkboxsoftware.com/c … submission
The relevant part of the code looks like this:

...
local maxFileToSubmit = SMTDPaths.tempdir + maxFileName
SMTDFunctions.SaveMaxFileCopy maxFileToSubmit

local SubmitInfoFile = SMTDPaths.tempdir + "\\max_submit_info.job"
local JobInfoFile = SMTDPaths.tempdir+ "\\max_job_info.job"

SMTDFunctions.CreateSubmitInfoFile SubmitInfoFile
SMTDFunctions.CreateJobInfoFile JobInfoFile

local initialArgs = "\""+SubmitInfoFile+"\" \""+JobInfoFile+"\" \""+maxFileToSubmit+"\" "
local result = SMTDFunctions.waitForCommandToComplete initialArgs SMTDSettings.TimeoutSubmission

local renderMsg = SMTDFunctions.getRenderMessage() -->BOBO: Here we get the render message after submission
SMTDFunctions.getJobIDFromMessage renderMsg -->BOBO: Here we call a function to extract the ID from the message

if result == #success then -->BOBO: If the submission was successful, 
(
format "Submitted successfully as Job %.\n\n%\n\n" \ -->we print the SMTDSettings.DeadlineSubmissionLastJobID and the message
SMTDSettings.DeadlineSubmissionLastJobID renderMsg -->which were extracted in the above two function calls!
)
else
format "Job Submission FAILED.\n\n%" renderMsg
)--end if
...

Note that the function SMTDFunctions.getRenderMessage() already knows to look in the file that the SMTDFunctions.waitForCommandToComplete() function has passed to DeadlineCommandBG to output its message to.
Of course, if you have the location of a text file that contains the output of DeadlineCommandBG, you can simply pass it on as argument to SMTDFunctions.getJobIDFromMessage() and the SMTDSettings.DeadlineSubmissionLastJobID property will be populated with the ID automagically!

Running the above macro simply opens the SMTD UI. The interesting thing about SMTD is that you don’t have to use the UI at all if you want to submit jobs using MAXScript. See the above link for the tutorial that shows a completely custom submission without ever touching the SMTD UI. That is my recommended workflow when using MAXScript with Deadline submissions.

Unfortunately, due to a bug in MAXScript (the event handler on … checked do() has the same name as the .checked property of the control), you cannot press the button programmatically via a MAXScript function call. It could be done via DotNet or Windows UI control access, but that would be a hacky way of doing it.

Within the event handler, a regular submission of a single camera without state sets generally ends up calling the function SMTDFunctions.SubmitJobFromUI() . So if you want to emulate a submission as if you pressed that button, you can call that function (after making sure all your SMTDSettings have the values you want in your job), and EVEN WITHOUT the SMTD UI being open, you will achieve the same result! Again, some special handling of stereo cameras, state sets, back rendering etc. are handled within the button’s event handler, so you would not get their effects unless you re-implement the logic yourself (or copy it from the SMTD UI code).
I plan to fix this in the future, but I don’t recommend pressing UI buttons with MAXScript anyway…

Please let me know if you have any further questions!

Privacy | Site terms | Cookie preferences