MEL How-To #93 | ||
| ||
How do I create a file dialog for which I can define the default starting directory?For Windows NT: For a file-selection dialog the ' string $selectedFile = `fileDialog -dm "D:\\joe\\mayastuff\\*.mb;*.ma"`; For a folder-selection dialog you can use the ‘ global proc browseForFolder( string $startFolder ) { string $mayaFolder; // Get current directory.. we'll restore this when we're done $mayaFolder = `workspace -q -dir`; // Set the current directory to our own. // Note that this will set Maya's workspace folder even // if the specified folder does not exist. workspace -dir $startFolder; // Present the user with a folder-selection dialog. // It will default to $startFolder. // The $mayaFolder is included as the first argument for the callback. fileBrowserDialog -mode 4 -fileCommand ( "browseForFolderCallback \"" + $mayaFolder + "\"" ) -actionName "Pick Your Folder"; } global proc browseForFolderCallback( string $mayaFolder, string $result, string $type ) { // Do whatever you need to with the $result print ( "Folder selection: " + $result + "\n" ); // Restore the original folder path workspace -dir $mayaFolder; } Example: browseForFolder( "C:/projects/gameData/" ); For IRIX: I know of only one command that will allow you to define the default directory for a file dialog. The command is not in the docs, but you can investigate it under the file: «maya_install_dir»\scripts\others\fileBrowser.mel You need to set a global variable to define the default starting location; e.g.: global proc myFileBrowserCB( string $file, string $fileType ) { print ( "File selected: " + $file + "\n" ); } global proc myFileBrowser() { global string $gDefaultFileBrowserDir; $gDefaultFileBrowserDir = "/usr/joe/mayastuff/"; fileBrowser( "myFileBrowserCB", "Open Joe's File", "mayaBinary", 0 ); } Suggestion to A|w: Please consolidate all ' | ||
Copyright ©2005 by Bryan Ewert, maya@ewertb.com Maya is a Registered Trademark of Alias |