I’m trying to submit two jobs one after the other and have the second job be dependent on the first using maxscript but I’m having some issues getting the submission to work. I’m not sure what I’m supposed to be putting in the SMTDSettings.DependencyJobItems to get it to go through! I’m getting the job number using SMTDSettings.DeadlineSubmissionLastJobID, setting SMTD.SubmitAsDependent to true and then I’m not sure what to do with SMTDSettings.DependencyJobItems.
Is there a list anywhere of what you need to supply for the different Settings within SMTDSettings? Or does anyone have a suggestion on what I should be doing to get this to work?
This is a bit tricky, since the SMTDSettings.DependencyJobItems is a bitarray containing the indices of the jobs added from the Dependencies rollout of the SMTD dialog.
In other words, if you are calling SMTDFunctions.CreateSubmitInfoFile() to make the submit info file, the only way to define a dependency is to populate the SMTDSettings.JobsArray array, find the index of the job that matches the ID you have from the previous job and set that index in the SMTDSettings.DependencyJobItems bitarray. This is a bit convoluted, but since these controls were made to be used via the SMTD UI and not pure MAXScript, there is no way around them.
The alternative is to build your own job info file, then you could simply set the key JobDependencies= to a comma-separated list of job IDs.
Here is a short overview of the necessary steps:
result = SMTDFunctions.CollectJobs userOnly:true --call this to populate the list of jobs after submitting the first job
--At this point, if the result is #success, the property SMTDSettings.JobsArray will contain all existing jobs by your current user
if result == #success do
(
local theIndex = 0 --initialize a variable to 0
--now loop through all the jobs and look for the one that matches the last ID (the job ID is the second element of the sub-array)
--once you have found it, record the index of the array item in the variable theIndex
for i = 1 to SMTDSettings.JobsArray.count where SMTDSettings.JobsArray[i][2] == SMTDSettings.DeadlineSubmissionLastJobID while theIndex == 0 do theIndex = i
--if the index was a positive number (meaning the job record was found), store it in the bitarray
if theIndex > 0 do SMTDSettings.DependencyJobItems = #{theIndex}
)
Thanks for the reply, I was looking at that section of code as that was were the error was dumping me. I think it’ll be best for me to populate the job info file after I’ve created it. Seeing as I have the Job ID already it adds a lot more time to get all jobs and then work out the index.
Good plan!
Just make sure you disable the Job Dependency option so no key is written by the createJobInfoFile function, then append to the existing file.