Working With Scene Files

MAXScript,and therefore pymxs, provides many methods for working with scene files, such as loading, saving, merging and archiving, as well as obtaining the current file path and name.

For example, to save the current scene file, and then query the file name and path:

>>> pymxs.runtime.saveMaxFile('myMaxFile.max')
True
>>> pymxs.runtime.maxFileName
u'myMaxFile.max'
>>> pymxs.runtime.maxFilePath
u'D:\\My Documents\\3dsMax\\scenes\\'

Note: The default scene file path is determined by the Project Paths setting, which can be accessed from the pathConfig struct.

Similarly, to load an existing scene file:

>>> pymxs.runtime.checkForSave()
True
>>> pymxs.runtime.loadMaxFile('my_scene.max')
True

Note: By default, loadMaxFile() replaces the current scene without warning, which is why we call checkForSave() first. This method will display the file save dialog if the current scene is modified and needs to be saved.

For more information about pymxs methods for working with scene files, see the "3ds Max File Loading and Saving" topic in the MAXScript Help.

External File Access

Although MAXScript provides many functions for accessing external (non-scene) files, using the native Python file access methods is preferable in most cases. For example, you can use pymxs.runtime.openFile() to open a file, and use the returned fileStream object to read the contents, but Python's open() is more 'Pythonic'.

For more information about pymxs functions for working with external files, see the "External File Access" group of topics in the MAXScript Help.