The following System Globals and Methods are used to access the file name and path and load, save, merge, import, and export 3ds Max scenes.
Contains a String value that defines the file name for the currently open scene.
It will be set automatically when the scene is loaded or saved using the loadMaxFile() and saveMaxFile() methods described below.
See also the How do I get the file name of the current scene? FAQ entry.
Contains a String value that defines the directory path for the currently open scene.
It will be set automatically when the scene is loaded or saved using the loadMaxFile() and saveMaxFile() methods described below.
See also the How do I get the file name of the current scene? FAQ entry.
The following methods are used to load, save, merge, import, and export 3ds Max scenes.
Returns true if the file was found and loaded successfully, false otherwise.
If useFileUnits:false , the file objects will be rescaled to the current System's unit scale.
If true , the System's unit scale will be changed to the File's unit scale.
This option will apply regardless of the Respect System Units in Files option setting in the System Units Setup dialog.
Loading a file with useFileUnits:true will not change the system units setting in the 3dsmax.ini file.
useFileUnits defaults to false for 3ds Max, true for Autodesk VIZ.
For details on the quiet: option, please see Quiet Mode.
WARNING! |
---|
loadMaxFile() will replace the current scene content with the file content without warning! The "The scene has been modified. Do you want to save your changes" prompt will not be issued when using this method, even when supplying quiet:false See CheckForSave() and saveMaxFile() further on this page to ensure the current content of the scene is not lost if it requires saving. |
<boolean>mergeMAXFile <filename_string> [<name_array>] [#prompt] \ [ [ #select ] #noRedraw ] \ [ #deleteOldDups | #mergeDups | #skipDups | #promptDups | #autoRenameDups ] \ [ #promptMtlDups | #useMergedMtlDups | #useSceneMtlDups | #renameMtlDups ]\ [ #promptReparent | #alwaysReparent | #neverReparent ] \ [ quiet:<bool> ] \ [ missingExtFilesAction: <actions> ] [ missingExtFilesList: <&variable> ] \ [ missingXRefsAction: <actions> ] [ missingXRefsList: <&variable> ]
All arguments are optional except the initial file name. The flag arguments can be specified in any order.
The arguments details are as follows:
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.
If specified causes the standard merge dialog to be opened.
If specified causes the newly merged objects to be selected when merged.
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.
Deletes existing scene objects with the same names as incoming objects, equivalent to a replace.
Ignore name conflicts, merge anyway resulting in possibly duplicated names.
Don't merge objects with duplicated names.
Throw up the duplicates resolution dialog for the user to choose.
Auto-renames the incoming objects that have names that already exist in the current scene. No dialog will pop up. Available in 3ds Max 2011 and higher.
Default, prompt the user when duplicated materials are found.
Merge using the incoming materials.
Merge using the scene materials.
Merge and rename duplicated incoming materials.
Don't ask the user, always reparent.
Don't ask the user, never reparent.
For details on the quiet: option, please see Quiet Mode
mergeMAXFile returns true if the file was found and loaded successfully. Returns false when the argument is a file with .DRF extension.
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.
Displays the standard 3ds Max file save dialog, returns the file name selected by the user, or the value 'undefined' if canceled.
If the optional filename: string argument is specified and it contains only a file name pattern, only the files matching the pattern will be displayed. If it also contains a file path, the content of the directory matching the pattern will be displayed.
No actual file saving will be performed, only the name of the selected file will be returned. You can perform the saving by passing the result of this function (as long as it is not 'undefined') as argument to saveMaxFile() documented further on this page.
Displays the standard 3ds Max file open dialog, returns the file name selected by the user, or the value 'undefined' if canceled.
If the optional filename: string argument is specified and it contains only a file name pattern, only the files matching the pattern will be displayed. If it also contains a file path, the content of the directory matching the pattern will be displayed.
If the optional dir: string is specified, the dialog will open at the specified path and the File name field will be set to the current scene file name (found in the maxFileName global variable), or will be empty if the scene is still Untitled.
Returns an array of strings, 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,
getMAXFileObjectNames returns an empty array when the argument is a file with .DRF extension.
For details on the quiet: option, please see Quiet Mode
getMAXFileObjectNames in 3ds Max 7 and higher returns an array of string values, rather than the array of name values in previous 3ds Max versions. The object names used by mergeMaxFile are case sensitive, and name values are not guaranteed to maintain the case of the string they wrap.
<bool>saveMaxFile <filename_string> [saveAsVersion:<integer>] [clearNeedSaveFlag:<bool>] [useNewFile:<bool>] [quiet:<bool>]
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.
WARNING! |
---|
saveMaxFile() will overwrite existing files with the same name without warning! See CheckForSave() and doesFileExist() further on this page! |
The optional keywords are true by default to match the existing behavior prior to 3ds Max 6, except when saving as a previous version in 3ds Max 2011 and higher where the useNewFile: is assumed false to prevent the previous version file from becoming the current file.
In 3ds Max 2011 and higher, if a valid previous version is specified using saveAsPrevious: , the scene will be saved in the file format of the specified previous version. In 3ds Max 2011 the valid value is 2010. In 3ds Max 2012, the valid values are 2010 and 2011. Any other value will save using the current version's format.
If clearNeedSaveFlag: is set to false , the file is saved, but the need save flag will not be cleared and 3ds Max will still consider the scene as changed and requiring saving.
If useNewFile: is false , the saved file is not set as the current scene file and the file is not put in the Most Recently Used list. This lets you save a backup file of the scene to a different name without the name becoming the current one or appearing on the list of recent files.
For details on the quiet: option which was added to this method in 3ds Max 8, please see Quiet Mode
The method will return true on success or false if the saving failed (for example if attempting to overwrite an existing read-only file) in 3ds Max 8 and higher.
Equivalent to the 3ds Max Edit > Hold operation.
Equivalent to the 3ds Max Edit > Fetch operation. For details on the quiet : option, please see Quiet Mode
Returns true if the specified file is a MAX file.
This method tests the internal structure of the file to see if it is consistent with a MAX file.
Returns false if the file is not a MAX file or if the specified file does not exist.
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.
If the optional keyword argument using: is supplied, the respective I/O class will be used to perform the import. This can be useful when multiple plug-ins support the same file format extension. Available in 3ds Max 8 and higher.
To see all available importer plug-in classes, you can access the .classes property of the importerPlugin value - it returns an array of all installed importer plug-ins:
See also the Import and Export Filters topic for MAXScript access to the settings of some Importer and Exporter plugins.
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.
If the selectedOnly keyword parameter is set to true , only selected nodes are exported. Defaults to false .
If the optional using: keyword argument is supplied, the respective I/O class will be used to perform the export. This can be useful when multiple plug-ins support the same file format extension. Available in 3ds Max 8 and higher.
To get an array of all available exporter plug-in classes, you can access the .classes property of the exporterPlugin value:
FOR EXAMPLE, |
In the example above, the export will use the first plug-in found in the array, which is by default the 3D_StudioExporterPlugin. |
See also the Import and Export Filters topic for MAXScript access to the settings of some Importer and Exporter plugins.
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.
NEW in 3ds Max 2011: If saveAsVersion: provides a value of 2010, the resulting file will be saved in the specified version's file format. Versions prior to 3ds Max 2010 are not supported. If any other value is specified, or if not specified at all, the current version's file format will be used.
For details on the quiet: option which was added to this method in 3ds Max 8, please see Quiet Mode
The method will return true on success or false if the saving failed (for example if attempting to overwrite an existing read-only file) in 3ds Max 8 and higher.
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.
The function returns false if the user cancels out of the save, true otherwise. The function itself does NOT perform any saving, it only issues the prompt if the scene has been modified and returns the user's decision about further actions. Any actual saving or checking for file existence have to be performed by the MAXScript code.
See also Exiting and Resetting3ds Max
WARNING! |
saveNodes() and saveMaxFile() will overwrite existing files with the same name without warning! |
FOR EXAMPLE |
You should always use doesFileExist() to make sure the target file does not exist and prompt if it does.
Here are two examples of using doesFileExist() for these cases: