Hi,
I am currently trying to let a user file to a directory and I then want to store the directory. To do so I use the fileBrowserDialog. I had difficulty with saving the actual path itself in a string until I came across this code on this site here by user called PythonBoy and I also saw the same tip in other places. Everything works perfectly now but I am a bit cofused and I hope someone can explain the following to me...How does browseForFolderFeedback get the variable $result? How does the fileBrowserDialog save the path??
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/" );
I would appreciate any clarification on this...am I just overlooking a simple programming
principle here or something??
Thanks!!!!
created
Sep '09
last reply
Sep '12
- 5
replies
- 6.3k
views
- 1
user
- 2
links