function to reset sticky settings - maxscript

I there a way to call a function to reset the sticky settings back to default?

To reset the SMTDSettings struct to Factory Defaults, you can first call

::SMTDSettings = copy ::SMTDSettingsFactory

This will ensure that every setting is reinitialized to its start up value before loading the sticky info from INI files. Otherwise, settings that are NOT sticky but session-specific would stay with their current value.
This, of course, is optional.

Then you need to call the following function:

SMTDFunctions.loadSettings()

This will check each setting against the local and global stickiness INI files to see if it should change its value based on the latest value stored in the local INI file.

At the end of these two calls, you should be in the initial state of the SMTDSettings, same as relaunching the SMTD.

If you are also interested in updating the SMTD dialog UI, you would also have to call

try(destroyDialog SMTD_StartupDialog_Rollout )catch() fileIn (getDir #userScripts+ "\\SubmitMaxToDeadline.ms")
The first line closes the SMTD dialog in case it is open, the second line loads the latest local copy of the UI script.

Nice one Bobo, just what I needed.

I had some stickys like SMTDSettings.TileBlowupMode = true that I need to clear for my script.

Thanks
Si

Oh, I might have missed your point then.

What I posted RESETS the values to factory defaults, then RELOADS the sticky settings.
But you want to REMOVE the sticky settings so they do not stick to their values anymore, but revert to their factory defaults.

That’s a completely different thing!

The sticky values are stored in a local INI file.
The file is located here:

SMTDPaths.InIFile

You can either
-reset the value temporarily
-write to the INI file to override the sticky value,
-delete the whole INI file to forget the latest user values while keeping the setting sticky for the future, or
-make the setting non-sticky by editing the Local or Global (Repository) stickiness controls.

Resetting the value means you just set the value in your code to the value you want before submitting. A lot of custom scripts like the Krakatoa Partitioning etc. do that for values they need to be different than what is in SMTD.
In other words, you would say

SMTDSettings.TileBlowupMode = false

and then call the functions for submission.

Overwriting the INI value would involve calling

setIniSetting SMTDPaths.InIFile "TilesRendering" "TileBlowupMode" "false"

Next time you open SMTD or reload the values like I described in my previous post, the sticky setting will get a value of “false”

Deleting the whole INI file would remove any knowledge of the latest values for sticky controls. But if the user goes and changes a sticky setting to something else, it will be back to an undesired state

deleteFile SMTDPaths.InIFile

If you call the reload functions now, all values will stay at their factory defaults.

Making the setting non-sticky involves opening the file “SubmitMaxToDeadline_StickySettings.ini” in your Repository\Submission\3dsmax\Main\ and adding/changing the entry

[TilesRendering] TileBlowupMode=false
If you would restart SMTD, the Tile Blowup Mode will not be sticky anymore and will not read from the SMTDPaths.InIFile.

Please let me know if any of these make any sense to you :slight_smile:

Yes, I will just use…

SMTDSettings.TileBlowupMode = false

I do have my own sticky ini file that saves the data that I want to use. So was thinking of just setting your one back to default. But if I don’t have to, I will not do that.

Since I have you here, just have a few questions…
Do I need to load the SubmitMaxToDeadline_Functions.ms everytime? Can I just…

if remoteScript == undefined do(
	remoteScript = @"\\gs01\F\DeadlineRepository7\submission\3dsmax\main\SubmitMaxToDeadline_Functions.ms"
	fileIn remoteScript
)

Or is it doing other things each time I load the script for a new render?

And Last for my still renders for tile jobs or no title jobs. It took a bit to get this working and want to make sure I’m not forgetting anything.
Does this look ok?

global SMTDSettings
global SMTDFunctions

if remoteScript == undefined do(
	remoteScript = @"\\gs01\F\DeadlineRepository7\submission\3dsmax\main\SubmitMaxToDeadline_Functions.ms"
	fileIn remoteScript
)

fn FN_To_Tile_Or_Not_To_Tile Do_Tile_Job = (
	SMTDFunctions.loadSettings()
	SMTDSettings.JobName = maxFileName
	SMTDSettings.Priority = 77
	SMTDSettings.TilesInX = 4
	SMTDSettings.TilesInY = 4
	SMTDSettings.comment = "Tile Job Test"
	SMTDSettings.SequentialJob = false
	SMTDSettings.SubmitAsDependent = false
	SMTDSettings.MachineLimit = 10000
	SMTDSettings.ChunkSize = 1
	SMTDSettings.TileBlowupMode = false
	
	SubmitInfoFile = SMTDPaths.tempdir + "\\max_submit_info.job"
	JobInfoFile = SMTDPaths.tempdir  + "\\max_job_info.job"

	if Do_Tile_Job == true then(
		maxFileToSubmit = SMTDPaths.submitSubFolder + maxFileName
		SMTDFunctions.SaveMaxFileCopy maxFileToSubmit
		SMTDSettings.RegionRenderingMode = #singleFrameTiles
		SMTDSettings.SingleTileJob = true
		SMTDSettings.TilesRendering = true
		SMTDSettings.SingleTileJobDependent = true
		SMTDSettings.SingleTileJobCleanup = true
		SMTDFunctions.CreateSubmitInfoFile SubmitInfoFile
		SMTDFunctions.CreateJobInfoFile JobInfoFile
		
		Result = SMTDFunctions.spawnTileJobs forceMaxFile:maxFileToSubmit
	)
	else(
		maxFileToSubmit = SMTDPaths.tempdir + maxFileName
		SMTDFunctions.SaveMaxFileCopy maxFileToSubmit
		SMTDSettings.RegionRenderingMode = #none
		SMTDSettings.SingleTileJob = false
		SMTDSettings.TilesRendering = false
		SMTDSettings.SingleTileJobCleanup = false
		SMTDSettings.SingleTileJobDependent = false
		
		SMTDFunctions.CreateSubmitInfoFile SubmitInfoFile
		SMTDFunctions.CreateJobInfoFile JobInfoFile
				   
		initialArgs="\""+SubmitInfoFile+"\" \""+JobInfoFile+"\" \""+maxFileToSubmit+"\" "
		Result = SMTDFunctions.waitForCommandToComplete initialArgs SMTDSettings.TimeoutSubmission
	)
	gc()
	if Result == true or Result == #success then(
		Print "Render Sent"
	)
	else(
		Print "Render FAIL"
	)
)
FN_To_Tile_Or_Not_To_Tile true

The above code does only work after I submit a job from the Real Deadline after a max restart so it looks like it is missing somthing.

Thanks again Bobo

Si

What I usually do is check
if SMTDFunctions == undefined do…

But…
Performing fileIn() from a remote location is SLOW. So in SMTD, I have code to first copy this file to the local scripts folder, then fileIn() from there. I also generate a startup script which, once you have launched SMTD the first time, reloads the local file when Max stats up. This is why opening SMTD is much faster when the remote script has not changed - we don’t even copy it over, and we don’t even have to reload the functions…

So you can surely improve performance by at least copying the file to (GetDir #userscripts) and fileIn() from there.

As for your other question, I will have to spend some time looking at your code, so I will post a bit later…

Ok, I used your script to submit jobs and they rendered and assembled the tiles without a problem.
BUT on my system the SMTDFunctions and SMTDSettings were already pre-loaded due to the startup system I mentioned in the previous post.

So I deleted the local copies of SMTD from the #userscripts folder, and forced the loading of the Functions file as you had it (just changed the path to my Repository). I submitted again, the tiles rendered and assembled correctly.

I would say it seem to be working more or less as expected. What problems did you encounter when running without opening SMTD first?

I’m still having lots of error.

In the SubmitMaxToDeadline_Function.ms
line 3526

format "TileJob=True\n"														to:submitInfoFile

Also line 3476

passIndex = rpmcaptureprops.getpassindexfromnumb previouslysubmittedJobs[i][2]

Here is a little bigger chunck of the code. What I need to do…

1 - setup Vray for lightcache
2 - send to deadline -Not Dependent
3 - cleanup and setup for IR
4 - send to deadline -AS Dependent of LC
5 - cleanup Setup render for Title Job
6 - Send to deadline - AS Dependent of IR
7 - Make it do Draft Job For the Tiles - AS Dependent of Tile Job

Now a job might be Brute force so I only do 6 and 7

I have done this setup for animations and works great. But as soon as I added the Tile jobs and draft it has all fell apart.

Any thoughts would be great. Thanks Bobo

clearlistener()
Global SMTDSettings
Global SMTDFunctions
Global Render_Range_Type
Global DL_Priority = 77
Global DL_Tiles_X = 4
Global DL_Tiles_Y = 4
Global Render_GI_1
Global Render_GI_2
Global Render_nth
Global GI_PATH = ""
Global Depend_JobName_JobId = #("","")
Global JobName = "Job_Name"
Global vr = renderers.current
Global Settings_Saved = false
------------------------------------------------------------------------------------------------------------------------------
----- Preload Stuff Load
------------------------------------------------------------------------------------------------------------------------------
if SMTDFunctions == undefined do(
	remoteScript = @"\\gs01\F\DeadlineRepository7\submission\3dsmax\main\SubmitMaxToDeadline_Functions.ms"
	fileIn remoteScript
)

----- Get Path --------
temp = filterString rendOutputFilename "\\"
for i = 1 to (temp.count - 1) do(
	GI_PATH = GI_PATH + temp[i] + @"\"
)
------------------------------------------------------------------------------------------------------------------------------
----- RenderSetup Save and Restore
------------------------------------------------------------------------------------------------------------------------------
fn FN_SaveRenderSetup =(
	Render_Range_Type = rendTimeType
	Render_GI_1 = vr.gi_primary_type
	Render_GI_2 = vr.gi_secondary_type
	Render_nth = rendNThFrame
	Settings_Saved = true
)

fn FN_RestoreRenderSetup =(
	rendSaveFile = true
	rendNThFrame = Render_nth
	rendTimeType = Render_Range_Type
	vr.gi_primary_type = Render_GI_1 
	vr.gi_secondary_type = Render_GI_2
	vr.lightcache_mode = 0
	vr.adv_irradmap_mode = 0
	vr.adv_irradmap_autoSaveFileName = ""
	vr.adv_irradmap_loadFileName = ""
	vr.lightcache_loadFileName = ""
	vr.lightcache_autosaveFileName = ""
	vr.lightcache_showCalcPhase = 1
	vr.gi_irradmap_showCalcPhase = true
	Settings_Saved = false
)
------------------------------------------------------------------------------------------------------------------------------
----- LC Setup and Clean
------------------------------------------------------------------------------------------------------------------------------
fn FN_Setup_LC Two_Pass =(
	rendSaveFile = false
	vr.gi_primary_type = 3
	vr.gi_secondary_type = 0
	if rendTimeType == 1 then(
		vr.lightcache_multipleViews = false
	)
	else(
		vr.lightcache_multipleViews = true
	)
	rendTimeType = 1
	vr.options_dontRenderImage = true
	vr.lightcache_autoSave = true
	vr.lightcache_showCalcPhase = 0
	vr.output_saveFile = true
	if Anim_Pass == #TwoPass_No then(
		vr.lightcache_autosaveFileName = GI_PATH + "LC_" + JobName + ".vrlmap"
	)
	else(
		vr.lightcache_autosaveFileName = GI_PATH + "LC_" + JobName + "_Anim.vrlmap"
	)
)

fn FN_Clear_LC =(
	rendSaveFile = true
	rendTimeType = Render_Range_Type
	vr.lightcache_autoSave = false
	vr.lightcache_mode = 2 -- from file
	vr.lightcache_loadFileName = vr.lightcache_autosaveFileName
	vr.lightcache_autosaveFileName = ""
	vr.gi_primary_type = Rnder_GI_1 
	vr.gi_secondary_type = Rnder_GI_2
	vr.options_dontRenderImage = false
)
------------------------------------------------------------------------------------------------------------------------------
----- IR Setup and Clean
------------------------------------------------------------------------------------------------------------------------------
fn FN_Setup_IR Two_Pass =()
fn FN_Clear_IR =()
------------------------------------------------------------------------------------------------------------------------------
----- Main Deadline Renderer
------------------------------------------------------------------------------------------------------------------------------
fn FN_SendRender Do_Tile_Job Send_Depend Submit_Type Two_Pass Add_Comment =(
	if Settings_Saved == false do()
	SMTDFunctions.loadSettings()
	SMTDSettings.JobName = maxFileName
	SMTDSettings.TransferCompressed = true
	SMTDSettings.Priority = DL_Priority
	SMTDSettings.TilesInX = DL_Tiles_X
	SMTDSettings.TilesInY = DL_Tiles_Y
	SMTDSettings.TileBlowupMode = false
	case Submit_Type of(  
		#LC:(
			FN_Setup_LC Two_Pass
			SMTDSettings.JobName = JobName + " LC"
			SMTDSettings.comment = Add_Comment + "LightCache for " + JobName + "                                                                            "
			SMTDSettings.SequentialJob = true
			SMTDSettings.MachineLimit = 1
			SMTDSettings.ChunkSize = 10000
		)
		#IR:(
			FN_Setup_IR Two_Pass
			SMTDSettings.JobName = JobName + " IR"
			SMTDSettings.comment = Add_Comment + "Irradiance Map for " + JobName + "                                                                          "
			SMTDSettings.SequentialJob = true
			SMTDSettings.MachineLimit = 1
			SMTDSettings.ChunkSize = 10000
		)
		#Render:(
			SMTDSettings.JobName = JobName + " Render"
			if Do_Tile_Job == #Tile_Yes then(
				SMTDSettings.comment = Add_Comment + "Tile Render for " + JobName + "                                                                				"
			)
			else(
				SMTDSettings.comment = Add_Comment + "Render for " + JobName + "                                                                				"
			)
			SMTDSettings.SequentialJob = false
			SMTDSettings.MachineLimit = 10000
			SMTDSettings.ChunkSize = 1
		)
	)
	SubmitInfoFile = SMTDPaths.tempdir + "\\max_submit_info.job"
	JobInfoFile = SMTDPaths.tempdir  + "\\max_job_info.job"
	------------------------------------------------------------------------------------------------------------------------------
	----- Sort Dependent
	------------------------------------------------------------------------------------------------------------------------------
	if Send_Depend == #Depend_Yes then(
		SMTDSettings.SubmitAsDependent = true
		SMTDSettings.DependOnPreviousJobMode = #none
		SMTDSettings.JobsArray = #(Depend_JobName_JobId)
		SMTDSettings.dependencyJobItems = #(1)		
	)
	else(
		SMTDSettings.SubmitAsDependent = false
--		SMTDSettings.DependOnPreviousJobMode = #none    --- not sure what to set this to
-- 		SMTDSettings.JobsArray = #()
-- 		SMTDSettings.dependencyJobItems = #()
	)
	------------------------------------------------------------------------------------------------------------------------------
	----- Sort Tile Job
	------------------------------------------------------------------------------------------------------------------------------	
	if Do_Tile_Job == #Tile_Yes then(
		maxFileToSubmit = SMTDPaths.submitSubFolder + maxFileName
		SMTDFunctions.SaveMaxFileCopy maxFileToSubmit
		SMTDSettings.RegionRenderingMode = #singleFrameTiles
		SMTDSettings.SingleTileJob = true
		SMTDSettings.TilesRendering = true
		SMTDSettings.SingleTileJobDependent = true  ------Hmmm not sure what this does
		SMTDSettings.SingleTileJobCleanup = true
		SMTDSettings.DraftSubmitJob = true
		SMTDSettings.SingleTileJobDraft = true

		SMTDFunctions.CreateSubmitInfoFile SubmitInfoFile
		SMTDFunctions.CreateJobInfoFile JobInfoFile
		Result = SMTDFunctions.spawnTileJobs forceMaxFile:maxFileToSubmit
	)
	else(
		maxFileToSubmit = SMTDPaths.tempdir + maxFileName
		SMTDFunctions.SaveMaxFileCopy maxFileToSubmit
		SMTDSettings.RegionRenderingMode = #none
		SMTDSettings.SingleTileJob = false
		SMTDSettings.TilesRendering = false
		SMTDSettings.SingleTileJobDependent = true
		SMTDSettings.SingleTileJobCleanup = false
		SMTDSettings.DraftSubmitJob = false
		SMTDSettings.SingleTileJobDraft = false
		
		SMTDFunctions.CreateSubmitInfoFile SubmitInfoFile
		SMTDFunctions.CreateJobInfoFile JobInfoFile
		initialArgs="\""+SubmitInfoFile+"\" \""+JobInfoFile+"\" \""+maxFileToSubmit+"\" "
		Result = SMTDFunctions.waitForCommandToComplete initialArgs SMTDSettings.TimeoutSubmission
	)
	
	SMTDFunctions.GetJobIDFromMessage(SMTDFunctions.GetRenderMessage())
	Depend_JobName_JobId = #(SMTDSettings.JobName, SMTDSettings.DeadlineSubmissionLastJobID)
	------------------------------------------------------------------------------------------------------------------------------
	----- Reset Settings
	------------------------------------------------------------------------------------------------------------------------------	
	case Send_Type of(  --- Setup For Render
		#LC:(
			FN_Clear_LC()
		)
		#IR:(
			FN_Clear_IR()
		)
		#Render:(
			FN_RestoreRenderSetup()
			gc()
		)
	)
	if Result == true or Result == #success then(
		Print "Render Sent"
	)
	else(
		Print "Render FAIL"
	)
)

/*  send this first */
FN_SendRender #Tile_Yes #Depend_No #Render #TwoPass_No "1 of 2 - "


/*  send this second */
FN_SendRender #Tile_No #Depend_No #LC #TwoPass_No "1 of 3 - "
FN_SendRender #Tile_Yes #Depend_Yes #Render #TwoPass_No "2 of 3 - "

I did a few tests after the last post. First I delete the Sticky.ini

sent the my function from the code in last post. All was great sent both render and draft

FN_SendRender #Tile_Yes #Depend_No #Render #TwoPass_No "1 of 2 - "

Then I sent the second set. This stopped the draft from working.

FN_SendRender #Tile_No #Depend_No #LC #TwoPass_No "1 of 3 - "
FN_SendRender #Tile_Yes #Depend_Yes #Render #TwoPass_No "2 of 3 - "

I then sent the first again. No Draft and anything I do after, Draft stops working.

FN_SendRender #Tile_Yes #Depend_No #Render #TwoPass_No "1 of 2 - "

The next step was to go though the SMTDSettingsStructure of 4 different jobs and see what changed.

Few things did like…

SMTDSettings.PoolName = "none"
SMTDSettings.OnComplete = "Nothing"
SMTDSettings.MaxVersionToForce = "none"
SMTDSettings.AssemblerPoolName = "none"	
SMTDSettings.AssemblerGroup = "none"
SMTDSettings.ChunkSize = 1 
SMTDSettings.SequentialJob = false
SMTDSettings.RegionUseMaxValues = true
SMTDSettings.PerformSanityCheck = true
SMTDSettings.RestartRenderer = false
SMTDSettings.TransferPool = "none" 
SMTDSettings.TransferGroup = "none"
SMTDSettings.MultiRegionCopyDraftConfig = false

So, I hard coded the changes in and still no luck. I’m really running out of ideas to look at.

Si

Do you have by any chance RPM installed?
That would explain the second error you mentioned.
I don’t have RPM and of course I never hit that code because the IF protects me from it:

if rpmdata != undefined and RPMDataNet != undefined and RPMDataNet.CustomSubmitStruct != undefined do --only if RPM is active ( --MODIFIED by grant -- first we collect the job dependencies based on our UI settings: -- we are getting this data again - rather then store it in the struct (as it shouldn't be stored restored) lets just grab it again as it is lightweight previouslysubmittedJobs = rpmdata.getcustglobstorage 10002 -- array of submitted jobs in this submission session doPassDependency = rpmdata.getcustglobstorage 10000 passDependencyList = rpmdata.getcustglobstorage 10001 if previouslysubmittedJobs == undefined do previouslysubmittedJobs = #() if doPassDependency == undefined do doPassDependency = False if passDependencyList == undefined do passDependencyList = #() if doPassDependency == true do ( for i in 1 to previouslysubmittedJobs.count do ( passIndex = rpmcaptureprops.getpassindexfromnumb previouslysubmittedJobs[i][2] if passDependencyList[passIndex] == true do ( if depJobIds.count != 0 do depJobIds += "," depJobIds += previouslysubmittedJobs[i][1] ) ) ) )

That code was injected by Grant Adam to perform RPM-specific operations, and some more initialization happens in the SMTD UI. So if you have ‘rpmdata’, ‘RPMDataNet’ and ‘RPMDataNet.CustomSubmitStruct’ != undefined, you would hit the line that you reported!

If you do have RPM installed, then we will have to look at what is necessary to initialize it without running the SMTD UI…
If you don’t have RPM installed, you should send me the whole dump of the MAXScript Listener after the error occurs so I can see the values of all variables at the time of the error…

No RPManager on my computer. I only get the error once in a great while.
The main issue is if I send a Tile job that depends on a prerender like light
Cache the draft job will not be submitted.

I was still trying to fix this dependency problem, when on the send second file I got the error.

This is the listener dump and an image of what line in SubmitMaxToDeadline.ms

FN_DeadLineRender()
"Render Sent"
"Render Sent"
-- Error occurred in i loop; filename: \\gs01\F\DeadlineRepository7\submission\3dsmax\main\SubmitMaxToDeadline_Functions.ms; position: 154526; line: 3450
--  Frame:
--   i: 1
--   called in CreateSubmitInfoFile(); filename: \\gs01\F\DeadlineRepository7\submission\3dsmax\main\SubmitMaxToDeadline_Functions.ms; position: 154583; line: 3452
--  Frame:
--   formattedComment: "Tile Job Test"
--   RPMDataNet: undefined
--   activeRegions: undefined
--   rendererClassString: undefined
--   theKeyword: "Whitelist"
--   theFile: undefined
--   oldJobName: "Test_Render_06.max"
--   doPassDependency: undefined
--   jobname: undefined
--   customPlugin: unsupplied
--   rendID: undefined
--   kvpIndex: undefined
--   previouslysubmittedJobs: undefined
--   paddingString: undefined
--   is_exr: undefined
--   theJobs: #(1)
--   passDependencyList: undefined
--   theSpecialLabel: undefined
--   rend_type: undefined
--   formattedJobName: "Test_Render_06.max"
--   SubmitInfofile: <File:C:\Users\simon\AppData\Local\Thinkbox\Deadline7\temp\\max_submit_info.job>
--   limitGroupsToUseArray: undefined
--   PADDING: undefined
--   reCount: undefined
--   pluginToUse: "3dsmax"
--   depJobIds: ""
--   frames: undefined
--   reManager: undefined
--   framesSS: undefined
--   LimitGroups: undefined
--   currentJobsArray: #()
--   theRenderOutput: undefined
--   filenameOnly: undefined
--   alreadyExported: undefined
--   customFrameSequence: ""
--   overrideExtraInfo: false
--   outputDirectoryIndex: undefined
--   is_fxr: undefined
--   filename: "C:\Users\simon\AppData\Local\Thinkbox\Deadline7\temp\\max_submit_info.job"
--   NotificationNote: undefined
--   rpmdata: undefined
--   rendererID: undefined
--   outputFilenameIndex: undefined
--   reExtension: undefined
--   customOutputFile: unsupplied
--   reFilenameOnly: undefined
--   groupBatch: undefined
--   frameMode: #both
--   theSlaveListString: "Node-01,Node-02,Node-03,Node-04,Node-05,Node-06,Node-07,Node-08,Node-09,Node-10,WORK31,WORK38,Work19,Work20,Work21,Work35,Work36,Work37,Work40,work30,work32,work33,work34"
--   includeBothOutputs: false
--   totalRegions: undefined
--   ChunkSize: undefined
--   theFilenameProps: undefined
--   reFilename: undefined
--   elementsToSkip: undefined
--   called in FN_DeadLineRender(); filename: R:\01_SCRIPTS\Render_Manager\Basic_tile_Job_02.ms; position: 2152; line: 51
--  Frame:
--   maxFileToSubmit: "C:\Users\simon\AppData\Local\Temp\Test_Render_06.max"
--   initialArgs: undefined
--   Depend: #Depend_Yes
--   SubmitInfofile: "C:\Users\simon\AppData\Local\Thinkbox\Deadline7\temp\\max_submit_info.job"
--   Depend_JobName_JobId: undefined
--   TileJob: #Tile_Yes
--   JobInfofile: "C:\Users\simon\AppData\Local\Thinkbox\Deadline7\temp\\max_job_info.job"
--   result: undefined
-- No ""get"" function for undefined
OK

also here is the code I was running…

global SMTDSettings
global SMTDFunctions


remoteScript = @"\\gs01\F\DeadlineRepository7\submission\3dsmax\main\SubmitMaxToDeadline_Functions.ms"
fileIn remoteScript


fn FN_DeadLineRender Depend TileJob = (
	SMTDFunctions.loadSettings()
	SMTDSettings.JobName = maxFileName
	SMTDSettings.Priority = 3
	SMTDSettings.TilesInX = 4
	SMTDSettings.TilesInY = 4
	SMTDSettings.comment = "Tile Job Test"
	SMTDSettings.SequentialJob = false
	SMTDSettings.SubmitAsDependent = false
	SMTDSettings.MachineLimit = 10000
	SMTDSettings.ChunkSize = 1
	SMTDSettings.TileBlowupMode = false

	SubmitInfoFile = SMTDPaths.tempdir + "\\max_submit_info.job"
	JobInfoFile = SMTDPaths.tempdir  + "\\max_job_info.job"
	------------------------------------------------------------------------------------------------------------------------------
	----- Sort Dependent
	------------------------------------------------------------------------------------------------------------------------------
	if Depend == #Depend_Yes then(
		SMTDSettings.SubmitAsDependent = true
		--SMTDSettings.DependOnPreviousJobMode = #previous
		SMTDSettings.JobsArray = #(Depend_JobName_JobId)
		SMTDSettings.dependencyJobItems = #(1)
	)
	else(
		SMTDSettings.SubmitAsDependent = false
		SMTDSettings.DeadlineSubmissionLastJobID = "none" 
		--SMTDSettings.DependOnPreviousJobMode = #previous
		SMTDSettings.JobsArray = #()
		SMTDSettings.dependencyJobItems = #()
	)
	------------------------------------------------------------------------------------------------------------------------------
	----- Sort Tile Job
	------------------------------------------------------------------------------------------------------------------------------	
	if TileJob == #Tile_Yes then(
		maxFileToSubmit = SMTDPaths.submitSubFolder + maxFileName
		SMTDFunctions.SaveMaxFileCopy maxFileToSubmit
		SMTDSettings.RegionRenderingMode = #singleFrameTiles
		SMTDSettings.SingleTileJob = true
		SMTDSettings.TilesRendering = true
		SMTDSettings.SingleTileJobDependent = true
		SMTDSettings.SingleTileJobCleanup = true
		SMTDFunctions.CreateSubmitInfoFile SubmitInfoFile
		SMTDFunctions.CreateJobInfoFile JobInfoFile

		Result = SMTDFunctions.spawnTileJobs forceMaxFile:maxFileToSubmit
	)
	else(
		maxFileToSubmit = SMTDPaths.tempdir + maxFileName
		SMTDFunctions.SaveMaxFileCopy maxFileToSubmit
		SMTDSettings.RegionRenderingMode = #none
		SMTDSettings.SingleTileJob = false
		SMTDSettings.TilesRendering = false
		SMTDSettings.SingleTileJobCleanup = false
		SMTDSettings.SingleTileJobDependent = false

		SMTDFunctions.CreateSubmitInfoFile SubmitInfoFile
		SMTDFunctions.CreateJobInfoFile JobInfoFile

		initialArgs="\""+SubmitInfoFile+"\" \""+JobInfoFile+"\" \""+maxFileToSubmit+"\" "
		Result = SMTDFunctions.waitForCommandToComplete initialArgs SMTDSettings.TimeoutSubmission
	)
	gc()
	if Result == true or Result == #success then(
		Print "Render Sent"
	)
	else(
		Print "Render FAIL"
	)
)
FN_DeadLineRender #Depend_No #Tile_No
FN_DeadLineRender #Depend_Yes #Tile_Yes

I’m just going to send this to support. I just running in circles now.

Can you please upload YOUR version of the SubmitMaxToDeadline_Functions.ms file?
The lines reported in the error dump would not correspond to mine (neither in Git nor in my own Repository) - the one is older, the other is newer…

The error “no get function for undefined” usually means an attempt to read an element of an undefined array.

Here it is. I’m so close now!!!
I has worked for what I need it to do.

But if I restart max I get that error.

global SMTDSettings
global SMTDFunctions
global Last_jobid
global SMTD_AutoLoadSuccessful
global SMTD_TilesRendering
global SMTD_RegionRendering
	
remoteScript = @"\\gs01\F\DeadlineRepository7\submission\3dsmax\main\SubmitMaxToDeadline_Functions.ms"
fileIn remoteScript

fn FN_DeadLineSend Tile_Job Send_Depend =(
	SMTDSettings.ChunkSize = 1
	SMTDSettings.SubmitSceneMode == #reposave
	SMTDSettings.JobName = maxFileName
	SMTDSettings.Priority = 3
	SMTDSettings.TilesInX = 4
	SMTDSettings.TilesInY = 4
	SMTDSettings.comment = "Tile Job Test"
	SMTDSettings.TileBlowupMode = false
	-------------------------------------------------------------------------------------------------------------
	--  Do Dependents
	-------------------------------------------------------------------------------------------------------------
	if Send_Depend == #Depend_Yes then(
		SMTDSettings.SubmitAsDependent = true
		SMTDSettings.DependOnPreviousJobMode = #default
		SMTDSettings.DependOnPreviousJob = true
 		SMTDSettings.JobsArray = #(Depend_JobName_JobId)
 		SMTDSettings.dependencyJobItems = #(1)
	)
	else(
		SMTDSettings.SubmitAsDependent = false
		SMTDSettings.DependOnPreviousJob = false
		SMTDSettings.JobsArray = #()
		SMTDSettings.DependencyJobItems = #{}
	)
	-------------------------------------------------------------------------------------------------------------
	--  Do Tile or Not
	-------------------------------------------------------------------------------------------------------------
	if Tile_Job == #Tile_Yes then(
		SMTDSettings.TilesRendering = true
		SMTDSettings.SingleTileJob = true
		SMTDSettings.SingleTileJobDependent = true
		SMTDSettings.SingleTileJobCleanup = true
		SMTDSettings.RegionRenderingMode = #singleFrameTiles
		
		local maxFileToSubmit = SMTDPaths.submitSubFolder + maxFileName
		if maxFileName == "" do maxFileToSubmit += "untitled.max"
		if (doesFileExist maxFileToSubmit) do deleteFile maxFileToSubmit
		SMTDFunctions.SaveMaxFileCopy maxFileToSubmit

		retCode = (SMTDFunctions.spawnTileJobs forceMaxFile:maxFileToSubmit)

		renderMsg = SMTDFunctions.getRenderMessage()
		SMTDFunctions.getJobIDFromMessage renderMsg	
	)
	else(
		SMTDSettings.TilesRendering = false
		SMTDSettings.SingleTileJob = false
		SMTDSettings.SingleTileJobDependent = false
		SMTDSettings.SingleTileJobCleanup = false
		SMTDSettings.RegionRenderingMode = #none
		
		local maxFileToSubmit = SMTDPaths.tempdir + maxFileName
		if maxFileName == "" do maxFileToSubmit += "untitled.max"
		if (doesFileExist maxFileToSubmit) do deleteFile maxFileToSubmit
		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() 
		SMTDFunctions.getJobIDFromMessage renderMsg
		
		Depend_JobName_JobId = #(SMTDSettings.JobName, SMTDSettings.DeadlineSubmissionLastJobID)
		print"------------------------"	
		print SMTDSettings.JobName
		print SMTDSettings.DeadlineSubmissionLastJobID
		print"------------------------"
		if result == #success then (
			format "Submitted successfully as Job %.\n\n%\n\n" \
			SMTDSettings.DeadlineSubmissionLastJobID renderMsg
			Last_jobid = SMTDSettings.DeadlineSubmissionLastJobID
		) 
		else (
			format "Job Submission FAILED.\n\n%" renderMsg 
		)
	)
	gc()
)
FN_DeadLineSend #Tile_No #Depend_No
FN_DeadLineSend #Tile_Yes #Depend_Yes

sorry forgot to attach main submit
SubmitMaxToDeadline_Functions.zip (77.3 KB)

Well, After changing the Jobs Array to Global. I can’t get it to crash

Looks like it is finally working.
Thanks for all your help.

Here is the working code if anyone wants it.

-------------------------------------------------------------------------------------
-- The AngryBear
-- Simon Donaghy
------------------------------------------------------------------------------------

clearlistener()
global SMTDSettings
global SMTDFunctions
global Depend_JobName_JobId
global SMTD_AutoLoadSuccessful
global SMTD_TilesRendering
global SMTD_RegionRendering
global ReadFunctions

if ReadFunctions == undefined do(
	ReadFunctions = @"\\gs01\F\DeadlineRepository7\submission\3dsmax\main\SubmitMaxToDeadline_Functions.ms"
	fileIn ReadFunctions
)

fn FN_DeadLineSend Tile_Job Send_Depend =(
	SMTDSettings.ChunkSize = 1
	SMTDSettings.SubmitSceneMode == #reposave
	SMTDSettings.JobName = maxFileName
	SMTDSettings.Priority = 3
	SMTDSettings.TilesInX = 4
	SMTDSettings.TilesInY = 4
	SMTDSettings.comment = "Tile Job Test"
	SMTDSettings.TileBlowupMode = false
	-------------------------------------------------------------------------------------------------------------
	--  Do Dependents
	-------------------------------------------------------------------------------------------------------------
	if Send_Depend == #Depend_Yes then(
		SMTDSettings.SubmitAsDependent = true
		SMTDSettings.DependOnPreviousJobMode = #default
		SMTDSettings.DependOnPreviousJob = true
 		SMTDSettings.JobsArray = #(Depend_JobName_JobId)
 		SMTDSettings.dependencyJobItems = #(1)
	)
	else(
		SMTDSettings.SubmitAsDependent = false
		SMTDSettings.DependOnPreviousJob = false
		SMTDSettings.DependencyJobItems = #{}
	)
	-------------------------------------------------------------------------------------------------------------
	--  Do Tile or Not
	-------------------------------------------------------------------------------------------------------------
	if Tile_Job == #Tile_Yes then(
		SMTDSettings.TilesRendering = true
		SMTDSettings.SingleTileJob = true
		SMTDSettings.SingleTileJobDependent = true
		SMTDSettings.SingleTileJobCleanup = true
		SMTDSettings.RegionRenderingMode = #singleFrameTiles
		
		local maxFileToSubmit = SMTDPaths.submitSubFolder + maxFileName
		SMTDFunctions.SaveMaxFileCopy maxFileToSubmit
		retCode = (SMTDFunctions.spawnTileJobs forceMaxFile:maxFileToSubmit)
		renderMsg = SMTDFunctions.getRenderMessage()
		SMTDFunctions.getJobIDFromMessage renderMsg
		
		if retCode == true then (
			format "Submitted successfully %" renderMsg
			
		) 
		else (
			format "Job Submission FAILED %" renderMsg 
		)
	)
	else(
		SMTDSettings.TilesRendering = false
		SMTDSettings.SingleTileJob = false
		SMTDSettings.SingleTileJobDependent = false
		SMTDSettings.SingleTileJobCleanup = false
		SMTDSettings.RegionRenderingMode = #none
		
		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() 
		SMTDFunctions.getJobIDFromMessage renderMsg
		
		Depend_JobName_JobId = #(SMTDSettings.JobName, SMTDSettings.DeadlineSubmissionLastJobID)

		if result == #success then (
			format "Submitted successfully as Job %.\n\n%\n\n" \
			SMTDSettings.DeadlineSubmissionLastJobID renderMsg
			Last_jobid = SMTDSettings.DeadlineSubmissionLastJobID
		) 
		else (
			format "Job Submission FAILED.\n\n%" renderMsg 
		)
	)
	gc()
)
FN_DeadLineSend #Tile_No #Depend_No
FN_DeadLineSend #Tile_Yes #Depend_Yes

That was helpful!

The error occurs here:

				local depJobIds = ""
				if SMTDSettings.SubmitAsDependent and (frameMode != #rest OR SMTDSettings.PreviewJobSecondJobDependentOnFirst == false) do
				(
					local theJobs = SMTDSettings.DependencyJobItems as array
					local currentJobsArray = case SMTDSettings.DependOnPreviousJobMode of
					(
						default: deepCopy SMTDSettings.JobsArray
						#previous: deepCopy SMTDSettings.PreviousJobsArray
						#last: 
						(
							if SMTDSettings.PreviousJobsArray.count > 0 then
								#(SMTDSettings.PreviousJobsArray[SMTDSettings.PreviousJobsArray.count])
							else
								#()
						)
					)
					for i = 1 to theJobs.count do
					(
						depJobIds += currentJobsArray[theJobs[i]][2] 
						if i < theJobs.count do depJobIds += ","
					)	
				)	

The problem is that the SMTDSettings.JobsArray might be set incorrectly by your code.
As you can see, the line ‘depJobIds += currentJobsArray[theJobs[i]][2]’ is looking for the sub-array element 2 of the array element with index theJobs[i]. This is because the JobsArray normally contains an array of arrays. See the definition of the function CollectJobs. There you will discover that the content of that array which you defined as

SMTDSettings.JobsArray = #(Depend_JobName_JobId)

should actually look like

SMTDSettings.JobsArray = #(#("Name",Depend_JobName_JobId,"3dsmax","UserName","Department","Group","Status"))

(In the definition of the original function, it looks like this: append tempArray #(theName,theID,thePlugin,theUser,theDept,theGroup, theStatus) )

Unless Depend_JobName_JobId was supposed to be an array, of course… I could not figure out where it came from.

In your case, all you care about is the Job ID, so you can say

SMTDSettings.JobsArray = #(#("",JobId,"","","","",""))

or even

SMTDSettings.JobsArray = #(#("",JobId))

as the rest of the sub-items after the ID are for display / search purposes in the UI only…