Unfortunately I can’t post the full code here as I have a very complex tool I’m working on, and for some reason I’m getting SEH exception in RenderFrame() when rendering the job on deadline. The code works locally fine, and on a single execution sending to deadline works fine too. But if I use the code in a loop to send multiple passes to Deadline it’s causing issues. If I open the pass from the deadline repository and render it locally it works.
The issue appears to come from the process of adding rendering elements in my script… to massively overly simplify things the process is this… and seems to cause the same error… any ideas?
[code] setWaitCursor()
Holdmaxfile()
for i = 1 to 2 do
(
makedir "Y:\\CGI_R&D\\_Scripts\\Helium_RP\\Test_Files" all:true
rendSaveFile = true
rendOutputFilename = "Y:\\CGI_R&D\\_Scripts\\Helium_RP\\Test_Files\\Render_15_.tga"
--Making MME Render Element
re = maxOps.GetCurRenderElementMgr()
re.addrenderelement (MultiMatteElement elementname:"MME_1")
theelement = re.getrenderelement (re.numrenderelements() - 1)
theelement.R_gbufIDOn = true
theelement.R_gbufID = 1
theelement.G_gbufIDOn = true
theelement.G_gbufID = 2
theelement.B_gbufIDOn = true
theelement.B_gbufID = 3
theelement.MatID = true
theelement.affect_matte_objects = true
--temp variables
tilesrendering = false
RenderCam = "Camera001"
thepassname = "rgb"
(
thetempfile = SMTDPaths.TempDir + maxfilename
print "THE TEMP FILE"
print thetempfile
if (doesFileExist thetempFile) do deleteFile thetempFile
SaveMaxFile thetempfile usenewfile:false
rendSaveFile = true
global SMTDSettings --this is the global variable that will contain the submission settings of SMTD
global SMTDFunctions --this is the global variable that will contain the submission functions of SMTD
local theNetworkRoot = "" --this variable will hold the network root path - the path to the Repository
local theHomeRoot = "" --this variable will hold the local home folder of Deadline
--------------------------------------
--MAIN SUBMISSION CODE
--------------------------------------
theNetworkRoot = "\\\\xxx.xxxxxxxxxxxx.com\\DeadlineRepository" --repository location
format "Network Root is '%'\n" theNetworkRoot
--First, we load the script file with the function definitions
local remoteScript = theNetworkRoot + "\\submission\\3dsmax\\SubmitMaxToDeadline_Functions.ms" --this is the file name on the Repository
local localScript = getDir #userscripts + "\\SubmitMaxToDeadline_Functions.ms" --to speed things up, we will copy it locally first, then we will load it
if doesFileExist remoteScript then --if the remote file exists,
(
deleteFile localScript --we delete the local file in case it exists already
copyFile remoteScript localScript --then we copy the remote file over
fileIn localScript quiet:true --and execute it (equivalent to Main Menu > MAXScript > Run Script...)
--At this point, SMTDFunctions should have been initialized to the latest version found on the Repository.
--Now we have to make sure all defaults (both global and local) are loaded, otherwise the SMTDSettings struct would contain factory defaults
SMTDFunctions.loadSettings()
--local TempMaxFile = maxfilepath + maxfilename
f = maxfilepath + maxfilename
SMTDSettings.JobName = getFileNameFile f + ":" + thepassname + " [HydraGen Submission]" --we could for example set the job name to the name of the max file and any custom text we want
SMTDSettings.Comment = "Submitted from HydraGen" --we could set the comment field
SMTDSettings.Priority = 50 --we can override the priority, for example we could increment the priority based on the order of the files or something else
--SMTDSettings.Group = tghgroup
SMTDSettings.ChunkSize = 1
SMTDSettings.restartrenderer = true
SMTDSettings.ignoreMissingDLLs = true
SMTDSettings.machinelimit = 0
SMTDSettings.SubmitSceneMode = #reposave --changed to +Mode in Deadline 5.1
--setIniSetting SMTDPaths.InIFile "Scripts" "RunPreLoadScript" "true"
--SMTD_MainRollout.Ui_report ("+Run Scripts: Run Pre-Load Script ENABLED automatically.")
--setIniSetting SMTDPaths.InIFile "Scripts" "PreLoadScriptFile" theFile
--SMTDSettings.PostLoadScriptFile = thefile
--SMTDSettings.RunPostLoadScript = true
--SMTDSettings.PreFrameScriptFile = thefile
--SMTDSettings.RunPreFrameScript = true
--##todo
--n.usenodesettings
SMTDSettings.regionrendering = false
--if n.usenodesettings == true then
(
--##todo get from node somehow?
SMTDSettings.regiontop = 0
SMTDSettings.regionleft = 0
SMTDSettings.regionbottom = 100
SMTDSettings.regionright = 100
)
(
--Note that the simple act of loading SMTDFunctions has also initialized a SMTDPaths struct with default paths - type 'show SMTDPaths' to see what paths are available
local SubmitInfoFilename = SMTDPaths.tempdir + "\\max_submit_info.job" --we define the submit info file name which will contain info about the submission settings
local JobInfoFilename = SMTDPaths.tempdir + "\\max_job_info.job" --and the job info file which will contain info about the job's settings (most of them can be changed in the job's Properties dialog of the Monitor
SMTDFunctions.CreateSubmitInfoFile SubmitInfoFilename --we then call the function to create a submit info file based on the current SMTDSettings values
--We also call the function to create a job info file. It will contain all info about the current scene like renderer settings, list of cameras etc.
--This function accepts optional overrides for the render output filename, the tiles to render and the camera to render.
--We can specify these if we know them: renderOutputOverride:"" tileString:"" forceCamera:""
SMTDFunctions.CreateJobInfoFile JobInfoFilename forceCamera:RenderCam --renderOutputOverride: could be set to a string that points at the network location to write the images from the scene being submitted instead of using the renderer's output settings!
--Now that we have all the files we need for a submission (the scene file, the submit info and the job info file), we can call the submitter!
--To do this, we will have to create an argument list to pass to DeadlineCommandBG
--local initialArgs = "\"" + SubmitInfoFilename + "\" \"" + JobInfoFilename + "\" \"" + f + "\" "
local initialArgs = "\"" + SubmitInfoFilename + "\" \"" + JobInfoFilename + "\" \"" + thetempfile + "\" "
print "initialARgs"
print initialArgs
--We call the DeadlineCommandBG with our arguments and the timeout (which you can customize)
local retcode = SMTDFunctions.waitForCommandToComplete initialArgs SMTDSettings.TimeoutSubmission
--Once the command returns, we can try to get the message from the message file. Even if it failed, the file could contain userul error info...
local renderMsg = SMTDFunctions.getRenderMessage()
SMTDFunctions.getJobIDFromMessage renderMsg --we can also extract the job ID from the render message - it will be stored in SMTDSettings.DeadlineSubmissionLastJobID
if retCode == #success then --if the return code from the call was #success, we show a positive message
(
format "File % submitted successfully as Job %.\n\n%\n\n" (filenameFromPath f) SMTDSettings.DeadlineSubmissionLastJobID renderMsg
SMTDFunctions.CopyExternalFilesToRepository() --copy files to main job
)
else --if the code was anything else, we print the message as error message
format "Remaining Frames Job Submission FAILED.\n\n%" renderMsg
)
)--end if root resolved
--deletefile thetempfile
)--end script
fetchmaxfile quiet:true
)
setArrowCursor()[/code]