3DS MAX - Maxscript to save a .max file

Hi!

I’m trying to use Deadline to do some non-render processing. As such I am submitting jobs to deadline with maxscript to evaluate my tasks.
I’ve been scouring the web to determine if this is a max problem, a maxscript problem (aka MY problem) or a deadline problem. I’ve vaguely eliminated the first two and am posting here.

My code is below:

[code]global fName = “C:/z_boxes/diagnostics/ScriptLogs.txt” --defines file path and name
global fs
if (doesFileExist fName) == false then --if the file does not exist, create it
(
createFile fName --creates the file
fs = openFile fName mode:“r+”
format “This is a diagnostic file, please do not tamper with it!\n” to:fs
format “--------------------------------------------------------\n” to:fs
flush fs --clear the file from memory
close fs --close the file stream
)

fn AppendFile = (global fs = openFile fName mode:“a+”) --opens the file
fn StartLog =
(
format “\n-------------------------\n” to:fs
format “%\n” localtime to:fs
format “-------------------------\n” to:fs
)
fn CloseFile =
(
–format “\n” to:fs
flush fs --clear the file from memory
close fs --close the file stream
)

AppendFile()
StartLog()
–Start Diganostic Logging Here

------------------------File Saving--------------------------------------
filePath = maxfilepath
filePath = “C:\z_boxes\diagnostics\”
fn SaveTheFile nameVariant = --File saving function
(
if testFileName = matchPattern (filePath + getFilenamefile maxfilename) pattern:("* - " + nameVariant + “*”) == true then
(
–saveNodes (objects as array) (filePath + maxfilename) quiet:true
if (saveNodes (objects as array) (filePath + maxfilename) quiet:true) == ok then
(
format “I’m trying to save %.\n” (filePath + maxfilename) to:fs
)
else ( format “I failed to save a .max file.\n” to:fs)
)
else
(
–saveNodes (objects as array) (filePath + getFilenamefile maxfilename + " - " + nameVariant + “.max”) quiet:true
if (saveNodes (objects as array) (filePath + getFilenamefile maxfilename + " - " + nameVariant + “.max”) quiet:true) == ok then
(
format “I’m trying to save %.\n” (filePath + getFilenamefile maxfilename + " - " + nameVariant + “.max”) to:fs
)
else ( format “I failed to save a .max file.\n” to:fs)
)
)
------------------------File Saving--------------------------------------

SaveTheFile “Unwrapped”
–End Diagnostic Logging Here
CloseFile()[/code]
When I send this script to Deadline in headless form I get the following in my diagnostic file:

When I navigate to that directory however, the .max file does not exist.
I was originally trying to save the file to a network drive, but changed the directory to my local machine to try and help debugging.

My question is this: is deadline putting this file somewhere else? I can’t seem to find it anywhere related to the job itself, even if I change the filePath to maxfilepath.
I am testing in 3DS Max 2009 SP1(64bit) and 3DS Max 2011 SP2 (64bit)

Please, if someone can help me out, I would greatly appreciate it!
Thank you.

There are different modes for Deadline to deal with maxpaths, depending on what version of Deadline you’re on, there is the submit scene file with job option or there is the scene file submission options.

By default, Deadline will save the current file and then send that .max file to the repository where the slaves will pull it from, but you can tell it to not submit the scene file and the blades will pull the .max file from the original directory, which I guess is what you want.

If you want to use SaveMaxFile() in maxscript, you will need to make sure that machine is working in workstation mode or it won’t be able to save a file. This is a license restriction imposed by 3dsmax, and there is an option in Deadline to submit a job in Workstation mode, it will just require a license of max.

What Dave said - you cannot save a .MAX files in network rendering mode due to a Max licensing limitation - you must be running in Workstation mode with the UI up and a Max license acquired. There are a bunch of other limitations imposed on MAXScript when the machine is in license-free netwrok mode - pretty much anything that requires UI access won’t work.

You can use the function isNetServer() in your script to check whether Max it running in network mode or interactive (Workstation) mode:
docs.autodesk.com/3DSMAX/14/ENU/ … D-2068.htm

Thanks guys, your information is helpful to a point.
I was hoping there would be a work around for that fact, especially when my log file seemed to report that the savenode function had returned ok.

Do either of you - or anyone else for that matter - know of any documentation which lays out what does work in headless vs workstation modes?

Thanks again!

I don’t think there is such documentation. For the most part, it is a “trial and error” thing - for example Thinkbox Software’s XMesh does work in slave mode because it does its saving independently from Max, but the general import/export/saving of Max itself are artificially blocked.
Then there is the whole “Need UI to run” class of MAXScript functionality - anything that requires the Modifier Stack or the Viewports to be active will fail.

That is terribly unfortunate.
I think by the time I am done with this project I will have enough trial and error documentation to write a book on what does/does not work.
For example:

exportFile (filePath + filename + ".dae" ) #noPrompt using:exporterPlugin.classes[x] will export a file for me just fine. In fact I can even export it to the same directory that I want to save my .max to.
But I had to do trial and error on getting the exportplugin as my original method - thanks to the maxScript help - did not work in headless mode yet the method I have now plus this simple export line works wonders!