The quitMAX()
function lets you exit 3ds Max under script control. This function is typically used in batch processing or render scripts. The function has the form:
quitMAX [ #noPrompt ] quiet:<boolean> exitCode:<int>
If the #noPrompt
optional argument is not specified and there are unsaved changes in the scene, 3ds Max will prompt with its standard save changes dialog. The quiet:<boolean>
argument does the same thing, and overrides the #noPrompt
option if both are specified.
If the optional exitCode
argument is specified, when 3ds Max exits a message of "3ds Max Ended with Unknown Reason (Exit Code X)" is printed to the console, where X is the specified integer. This can be useful for batch processing scripts using 3dsmaxbatch.exe that want to get user-specified status codes from the application.
Additionally, you can control the scene save and undo states in 3ds Max with the following functions:
setSaveRequired <boolean> [autobackupRequired:<boolean>]
Lets you set the 3ds Max system "dirty" flag. If this flag is set or there are entries in the Undo buffer, the user is asked if they want to save the scene file on a File > New or File > Reset.
The optional autobackupRequired:<boolean>
keyword argument lets you specify whether an autobackup is also required. If not specified, the default value is the same as the first <boolean>
passed to setSaveRequired
.
getSaveRequired()
Returns true
if the 3ds Max system "dirty" flag is set to true
or if the Undo buffer is not empty. If the Undo buffer if not empty, this function will still return true
, even if you just called setSaveRequired false
.
clearUndoBuffer()
Empties the Undo buffer, both providing a way to reset the undo state and another way to control the save-changes requester.
Normally, if there are entries in the Undo buffer when the scene is closed, 3ds Max will prompt with a save-changes requester. In some cases, where you are controlling undo in MAXScript, you may want to force the need for a save-changes prompt.
The resetMAXFile()
function lets you reset 3ds Max under script control. This function is typically used in batch processing or render scripts. The function has the form:
resetMaxFile() [#noPrompt] [quiet:<boolean>]
If the #noPrompt
optional argument is not specified, 3ds Max will prompt with its standard dialog "Do you really want to reset".
checkForSave()
. See 3ds Max File Loading and SavingFOR EXAMPLE:
--CheckForSave checks whether the scene has been modified
--and issues the standard "Do you want to save your changes" dialog.
--If the user presses Yes or No, the function returns true and
--resetMaxFile will be called.
--If the user presses Cancel, the function returns false and
--resetMaxFile will not be called.
if checkForSave() do resetMaxFile()