3ds max File Loading and Saving

The following methods are used to load, save, merge, import, and export 3ds max scenes.

loadMaxFile <filename_string>

Returns true if the file was found and loaded successfully.

mergeMAXFile <filename_string> [ <name_array> ] [ #prompt ] \

           [ [ #select ] #noRedraw ]                        \

           [ #deleteOldDups | #mergeDups | #skipDups | #promptDups ]

All arguments are optional except the initial file name. The flag arguments can be specified in any order. The arguments details are as follows:

<name_array>

An optional array of names or strings identifying the objects in the source scene file to be merged; all objects are merged if not specified.

#prompt

If specified causes the standard merge dialog to be opened.

#select

If specified causes the newly merged objects to be selected when merged.

#noRedraw

If specified causes the screen redraw to be delayed in case you want to call mergeMAXFile several times and delay the redraw until after the last file merge.

#deleteOldDups

Deletes existing scene objects with the same names as incoming objects, equivalent to a replace.

#mergeDups

Ignore name conflicts, merge anyway resulting in possibly duplicated names.

#promptDups

Throw up the duplicates resolution dialog for the user to choose.

Returns true if the file was found and loaded successfully.

If you don't specify a full path name, the file is looked for in the 3ds max scene directory, then in the 3ds max executable directory, and then in the PATH environment directories.

getMAXSaveFileName filename: <seed_filename_string>

Displays standard 3ds max file save dialog, returns file name or value 'undefined' if canceled.

getMAXOpenFileName filename: <seed_filename_string> dir:<seed_directory_string>

Displays standard 3ds max file open dialog, returns file name or value 'undefined' if canceled.

getMAXFileObjectNames <max_filename_string>

Returns an array of names, one for each of the names of the objects in the given 3ds max file. This provides a way to get a preview list of the objects in another scene file (by name) to set up user selection of the objects to be merged under script control using the mergeMAXFile() function, for example.

Example:

p=[1000,1000,1000]

for i = 1 to 5 do box pos:(random p -p) -- create some boxes

savemaxfile "mergetest.max" -- save to file

for obj in objects do obj.name = "_"+obj.name -- rename the boxes

objects.pos += [0,-1000,0] -- move them off to the side

fobj_names = getmaxfileobjectnames "mergetest.max" -- get the object names from the file

deleteitem fobj_names 3 -- delete the third name from the array

mergemaxfile "mergetest.max" fobj_names #select -- merge in the objects and select them

selection.count -- should be 4

objects.count -- should be 9

saveMaxFile <filename_string>

Saves the scene to the current 3ds max scene directory if there is no explicit directory path on the supplied file name. If no filename extension is specified, ".max" is automatically appended to the filename.

holdMaxFile()

Equivalent to the 3ds max Edit > Hold operation.

fetchMaxFile()

Equivalent to the 3ds max Edit > Fetch operation.

importFile <filename_string> [ #noPrompt ]

Lets you import files using any of the import plug-ins that are available. The kind of file imported is determined by the file name suffix such as DFX for .dxf, 3DS DOS for .3ds, etc.

The #noPrompt flag prevents any configuration or control dialogs from being displayed in which case the default configuration is used.

exportFile <filename_string> [ #noPrompt ]

Lets you export files using any of the export plug-ins that are available. The kind of file exported is determined by the file name suffix such as DFX for .dxf, 3DS DOS for .3ds, etc.

The #noPrompt flag prevents any configuration or control dialogs from being displayed in which case the default configuration is used.

saveNodes <node_collection> <filename_string>

Creates a new .max scene file with the given name and stores the node collection to it. The <node_collection> argument can be a single node, an array of nodes you gathered, a wild-card path name, one of the built-in objects sets such as selection or lights, or a <node>.children array. If no filename extension is specified, ".max" is automatically appended to the filename.

checkForSave()

If the scene has been modified since the last file save (if any), calling this function displays the message box prompting the user that the scene has been modified and requests to save. Function returns false if the user cancels out of the save, true otherwise.

See also