Go to: Synopsis. Return value. Flags. MEL examples.

Synopsis

fileDialog2 [-cancelCaption string] [-caption string] [-dialogStyle int] [-fileFilter string] [-fileMode int] [-okCaption string] [-returnFilter boolean] [-selectFileFilter string] [-startingDirectory string]

fileDialog2 is undoable, NOT queryable, and NOT editable.

This command provides a dialog that allows users to select files or directories.

Return value

string array

Flags

cancelCaption, caption, dialogStyle, fileFilter, fileMode, okCaption, returnFilter, selectFileFilter, startingDirectory
Long name (short name) Argument types Properties
-dialogStyle(-ds) int create
  • 1 On Windows or Mac OS X will use a native style file dialog.
  • 2 Use a custom file dialog with a style that is consistent across platforms.
-caption(-cap) string create
Provide a title for the dialog.
-startingDirectory(-dir) string create
Provide the starting directory for the dialog.
-fileFilter(-ff) string create
Provide a list of file type filters to the dialog. Multiple filters should be separated by double semi-colons. See the examples section.
-selectFileFilter(-sff) string create
Specify the initial file filter to select. Specify just the begining text and not the full wildcard spec.
-fileMode(-fm) int create
Indicate what the dialog is to return.
  • 0 Any file, whether it exists or not.
  • 1 A single existing file.
  • 2 The name of a directory. Both directories and files are displayed in the dialog.
  • 3 The name of a directory. Only directories are displayed in the dialog.
  • 4 Then names of one or more existing files.
-okCaption(-okc) string create
If the dialogStyle flag is set to 2 then this provides a caption for the OK, or Accept, button within the dialog.
-cancelCaption(-cc) string create
If the dialogStyle flag is set to 2 then this provides a caption for the Cancel button within the dialog.
-returnFilter(-rf) boolean create
If true, the selected filter will be returned as the last item in the string array along with the selected files.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can be used more than once in a command.

MEL examples

// Single file filter with no description.
string $basicFilter = "*.mb";
string $result[] = `fileDialog2 -fileFilter $basicFilter -dialogStyle 2`;

// Single filter with a description.
string $singleFilter = "All Files (*.*)";
string $result[] = `fileDialog2 -fileFilter $singleFilter -dialogStyle 2`;

// Multiple filters separated by double semi-colons. The first filter has multiple file types.
string $multipleFilters = "Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)";
string $result[] = `fileDialog2 -fileFilter $multipleFilters -selectFileFilter "Maya Binary" -dialogStyle 2`;