Standard Open and Save File Dialogs

The following methods display the standard 3ds Max file open, file save, or folder selection browser dialog:

getOpenFileName [ caption:<title> ] \

[ filename:<seed_filename_string> ] \

[ types:<description1>|<pattern1>|<description2>|<pattern2>|...| ]

 

getSaveFileName [ caption:<title>] \

[ filename:<seed_filename_string> ] \

[ types:<description1>|<pattern1>|<description2>|<pattern2>|...| ]

Both functions return a fully-specified file path name or undefined if the user cancels out.

When the optional keyword filename: is supplied, the string is used to define the path and file name of the file to be loaded or saved. The dialog automatically navigates to the specified path (if available on the disk/network), displays its content in the browsing area and suggests the file name in the "File name" field. If the path does not exist, the current path is used and only the file name is displayed as requested.

For example

f = getOpenFileName caption:"Open A Test File:" filename:"c:/test/test.txt"

--if the path exists, will result in something like:

 getOpenFileName_test.gif

 

The types: parameter lets you specify custom file types and suffixes for the file type drop-down list in the open and save dialogs. You supply a string for this argument that is formatted in a special way, as follows:

"<description1>|<pattern1>|<description2>|<pattern2>|...|"

In other words, a sequence of file type descriptions and file type patterns each separated by a '|' vertical bar and terminated by a '|' vertical bar.

For example:

f = getOpenFileName \

types:"Data(*.dat)|*.dat|Excel(*.csv)|*.csv|All|*.*|"

Specifies three types in the file type drop-down list, the first reading "Data(*.dat)" and matching *.dat and the second reading "Excel(*.csv)" and matching *.csv and the third reading "All" and matching any file.

The getSaveFileName() function tests for the pre-existence of the file with the chosen file type suffix added.

 

getSavePath [caption:<window_caption_string>] [initialDir:<pathname>]

This function displays a folder selection browser for the user to select a folder. Returns a string path name for the selected folder or the value undefined if the user presses Cancel in the folder browser.

If the initialDir: keyword argument is specified, the Browse For Folder dialog will be opened at the specified directory. Symbolic pathnames are acceptable as the pathname. Available in 3ds Max 8 and higher.

Examples:

getSavePath caption:"my title" initialDir:"$scripts"

getSavePath caption:"my title" initialDir:(getDir #maxroot)

See also

Filestream Values

External File Methods

File Name Parsing