/
fileChooser

fileChooser

Description

Prompts the user to select a file on the file system in the system File Browser.

The File Browser is a dialog box designed for easy file/file name selection. By default, the File Browser does not filter on file types, however, filters can be provided using the -filters flag. The filters string is contains a sequence of filter descriptions, followed by the actual filter (eg, .c3d). Descriptions and extensions are separated using the | character, as are subsequent descriptions and extensions. For example, to filter on .c3d and .csm files, a filters string will look like this:

"Binary Motion File (.c3d)|.c3d|Character Studio (.csm)|.csm"

An All Files (.*) will automatically be appended to any filter string specified.

If the user hits the Cancel button (i.e. chooses no directory) and -failOnCancel is specified, the command will fail, causing the calling script to abort.

If -failOnCancel is not specified, the command will return an empty string ("").

Because the file must return multiple file paths if the -multi flag is specified, the command must return an array of strings. If -multi is not specified, a one element string array will be returned.

Note that in HSL, directories in file paths are separated by forward-slashes ( / ), rather than back-slashes ( \ ).

Functional area

User Window

Command syntax

Syntax

fileChooser [-owner integer] [-ext string] [-file string] [-dir string] [-filters string] [-multi] [-createPrompt] [-mustExist] [-failOnCancel]

Arguments

None

Flags

NameFlag argumentsArgument typeExclusive toComments
owner1integerSpecifies the window ID of a user window to be the "owner" of the File Browser. Essentially centers the Browser to the User Window.
ext1stringThe default file extension (e.g. c3d) to append to the selected filename, if it does not have one. The default is no action.
file1string
dir1stringSpecifies the initial directory of the File Browser when it is displayed. The default is the current directory.
filters1stringSpecifies the file type filters. By default, the File Browser displays all files. Files can be filtered down by extension, or even by fileClose
multi0
createPrompt0
must exist0
failOnCancel0
mustExist0

Return value

string array

Examples

// Prompt the user to select file.
string  $files[]; 
string  $initialPath = "C:/";
string  $filter = "Binary Motion File (*.c3d)|*.c3d|Character Studio (*.csm)|*.csm";
 
// Specify the initial directory, the filters, and that the file they
// select must exist.
$files = `fileChooser -dir $initialPath -filters $filter -mustExist`;
print $files;

Additional information

Related commands