Adding pre-render maxscripts to 3ds Max submissions

Hi there,

just want to ask where I should look for an option to add a user specified pre-render Maxscript during the submission?

I’ve looked into the .PY files in both the job plugins and the submission scripts folders, but I can’t really make up where to place this flag/option so I can modify the submission dialog to include a line for a Pre-Render MAXScript (for some automation processes).

Thanks a lot in advance for any tips in this regard.

Cheers…

I think you want the “PreFrameScript=” flag, which would be executed before each frame is rendered. If you are looking to execute the script only after the scene file is loaded, then you can use the “PostLoadScript=” flag. You can find how the 3dsmax submitter sets this in the SubmitMaxToDeadline_Functions.ms file in \your\repository\submission\3dsmax.

Hope that helps!

  • Ryan

Thank you, seems like it shouldn’t be a problem. Let’s see in practice… :sunglasses:

Nope, no problem at all… :sunglasses:

[attachment=0]winXP_Pro_x86-2011-04-14-00-48-28.png[/attachment]

Altough I’m afraid I broke the integrated 3ds Max submission scripts since you had hard-coded the submission of the PreLoad etc… scripts with the scene file. However, when I modified the scripts, the 3ds Max plugin script assumed automatically a stripped down file-name of the script itself and combined it with the path leading to the Deadline jobs directory. I had to modify that so the whole process preserved the correct, full, path to the script file itself. I assume I’d have to modify the integrated Deadline submission script in Max as well to reflect this change.

Yeah, you would have to, otherwise the plugin won’t be able to find the script. The other solution is to just handle both cases in the 3dsmax plugin. For example:

		self.PreLoadScript = GetPluginInfoEntryWithDefault( "PreLoadScript", "" ).strip().strip( "\"" )
		if( self.PreLoadScript != "" ):
			if( not Path.IsPathRooted( self.PreLoadScript ) ):
				self.PreLoadScript = Path.Combine( GetJobsDataDirectory(), self.PreLoadScript )
			LogInfo( "Pre load script: %s" % self.PreLoadScript )

So if the path isn’t rooted, the plugin will build the path to the job folder. If it is rooted, it will just use that path.

Cheers,

  • Ryan

A very good point, Ryan, thanks! I’ll check this one out and if it works, I’ll release the modified submitter here so you can decide if you want to bundle it with Deadline. :slight_smile: What do you say?

Sounds good to me! :slight_smile:

Perfect! :slight_smile:

Ok, your modification (obviously) works, just tested it. So the modified submission and plugin scripts for 3ds Max are done and working.

Here they are:

3dsMax_scripts.zip (19.5 KB)

Thanks!! We’ll probably include these in the 5.0 release.

That’d be great!

Also, one last modification I’d like to make is when the job is submitted, but suspended, if I want to change the properties of the job and I want to change my script files that’ll get submitted with the job, what file do I have to modify? Is it the 3dsmax.options?

Yup! That’s the file.

Thanks, it works, however, I have two questions:

  1. Why do the 3ds max properties only show controls for parameters that have been submitted with the file?

(under the scripts category)
[attachment=0]winXP_Pro_x86-2011-04-15-11-45-45.png[/attachment]

The code I used:

[PreFrameScript] Type=filename Label=PreFrame Script Category=Scripts Description=A MAXScript file which gets executed BEFORE each rendered frame. Required=false DisableIfBlank=false Default= index=40

  1. Why are they sorted alphabetically? Can I override this? (I though using the index property would do that, but it doesn’t).

Thanks in advance!

That’s done by design. These two properties define this behavior:

Required=false DisableIfBlank=true

If you want an option to always be shown, you could do this:

This is for a string property, which is why the Default is blank. As an alternative though, you could have your submitter always specify these properties:

writer.WriteLine( "PreLoadScript=%s" % preLoadFile )
writer.WriteLine( "PostLoadScript=%s" % postLoadFile )
writer.WriteLine( "PreFrameScript=%s" % preFrameFile )
writer.WriteLine( "PostFrameScript=%s" % postFrameFile )

If preLoadFile is blank, it won’t be executed by the max plugin, so you’re safe there, and because the property is defined in the plugin info file, it should appear in the 3dsmax job properties tab.

In order to completely control the order within a category, each property in that category should specify an index. Also, “index” needs to be capitalized. :slight_smile:

[PreFrameScript] Type=filename Label=PreFrame Script Category=Scripts Description=A MAXScript file which gets executed BEFORE each rendered frame. Required=false DisableIfBlank=false Default= Index=40

Finally, we’ll be updating 3dsmax.py in the next release to support absolute paths to scripts, but in the Monitor script, we’ll continue to strip the paths and submit the script files with the job to maintain consistency with SMTD. Thanks again for the code!

Cheers,

  • Ryan

Thank you very much, Ryan!

All works perfectly fine. :slight_smile:

Here are the latest scripts I modified if you want to include them in the release: 3dsMax_Deadline_Scripts.zip (41.4 KB)

Glad to hear it! We probably won’t include the changes to 3dsmax.options with the release because those only work when the maxscript files are on the network and aren’t being submitted with the job. Because SMTD and our out-of-the-box monitor submitters submit the maxscript file with the job, it doesn’t really make sense to expose an option to change it.

Cheers,

  • Ryan

Ah, sure thing, no problem. I’ll add these to the Deadline downloads as an option, then. :slight_smile:

Btw, I could update the scripts so they’d submit the script files as well if the option is checked. Would this help?

A problem I see is that the the options file won’t be able to differentiate if the script file is a full path or just a file name, and we shouldn’t be showing the option if it’s just a file name. We would almost need separate property names for if it’s a full path or not. Because we’re so close to the end of the beta, we’re hesitant to add any additional features at this point, but I’m sure we can take another look during the next beta.

Cheers,

  • Ryan

Absolutely! Yeah, that’s probably a better option, since it might require some under the hood additions. :slight_smile:

Thank you and keep the great work up! Deadline 5 will rock!