// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: Feb, 2000 // // // // // // // loadNewShelf (string $file) // // // None. // // // This procedure opens a shelf file and loads the shelf // into the current session. The shelf will be saved in // the users shelf directory. //

// NOTE: The file must be along the script path to be found. // // // string $file The name of the shelf file. // If null then the user is prompted for a name. // // // loadNewShelf ""; // // global proc loadNewShelf (string $file) { // remember the last directory used global string $gShelvesDirectoryName = ""; if ($gShelvesDirectoryName == "") { $gShelvesDirectoryName = ( getenv("MAYA_LOCATION") + "/scripts/shelves/" ); } string $fileName = $file; if ($fileName == "") { // If the file name is blank then prompt the user string $fileFilter = (uiRes("m_loadNewShelf.kShelfFiles")) + " (*.mel) (*.mel)"; string $userChoice[] = `fileDialog2 -fileMode 1 -startingDirectory $gShelvesDirectoryName -fileFilter $fileFilter -caption (uiRes("m_loadNewShelf.kLoadShelf"))`; if ( (size($userChoice) > 0) && ($userChoice[0] != "") ) { $fileName = fromNativePath($userChoice[0]); } if ($fileName == "") { // The user cancelled the dialog return; } } // The procedure we will run is the name of the file // without the .mel extension // string $buffer[]; int $numTokens = `tokenize $fileName "/" $buffer`; string $shortFileName = $buffer[$numTokens - 1]; // The double backslash is to prevent the '.' from being // used as a wildcard. // string $proc = `substitute "\\.mel" $shortFileName ""`; // Get the directory specified to make life a little easier // next time around // $gShelvesDirectoryName = `substitute $shortFileName $fileName ""`; // The name of the shelf will be the name of the // procedure without the shelf_ prefix // string $name = `substitute "shelf_" $proc ""`; if ($proc == "" || $name == "") { error (uiRes("m_loadNewShelf.kNotShelfFile")); return; } // Check to see if a shelf already exists with this name // global string $gShelfTopLevel; setParent $gShelfTopLevel; if (`shelfLayout -exists $name`) { error (uiRes("m_loadNewShelf.kShelfAlreadyExist")); return; } // Make sure the file is okay // if (exists($fileName)) { string $shelfScriptCmd = "source \""+$fileName+"\";"; eval ($shelfScriptCmd); } else { error (uiRes("m_loadNewShelf.kFileNotFound")); return; } // Create a new shelf // string $shelfName = `addNewShelfTab $name`; if ($shelfName == "") { error (uiRes("m_loadNewShelf.kCouldNotCreateTab")); } }