// Copyright (C) 1997-2006 Autodesk, Inc., and/or its licensors. // All rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files contain unpublished // information proprietary to Autodesk, Inc. ("Autodesk") and/or its licensors, // which is protected by U.S. and Canadian federal copyright law and by // international treaties. // // The Data is provided for use exclusively by You. You have the right to use, // modify, and incorporate this Data into other products for purposes authorized // by the Autodesk software license agreement, without fee. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. AUTODESK // DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTIES // INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF NON-INFRINGEMENT, // MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ARISING FROM A COURSE // OF DEALING, USAGE, OR TRADE PRACTICE. IN NO EVENT WILL AUTODESK AND/OR ITS // LICENSORS BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL, // DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS // LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES. // // Alias Script File // MODIFY THIS AT YOUR OWN RISK // // // // // // // // menuItemToShelf (string $itemName) // // // None. // // // Creates a button on the current shelf that, when pressed, will // act like selecting the specified menu item. // // // string $itemName Name of the menu item. (Not the label) // // // menuItemToShelf "selectAllItem"; // // global proc menuItemToShelf (string $itemName) { global string $gShelfTopLevel; string $currentShelf; if (`tabLayout -exists $gShelfTopLevel`) { $currentShelf = `tabLayout -q -st $gShelfTopLevel`; setParent ($gShelfTopLevel + "|" + $currentShelf); // // check for current shelf style and size here // // Get the image for the shelf button. // string $image = `menuItem -query -image $itemName`; string $imageOverlayLabel = ""; if ("" == $image) { $image = `menuItem -query -familyImage $itemName`; if ("" == $image) { $image = "commandButton.xpm"; } // // Create an image overlay label if necessary // $imageOverlayLabel = `menuItem -q -iol $itemName`; if ("" == $imageOverlayLabel) { // // Use the first character of each word in the // menuItem -label if it is more than one word // else use the first 3 characters of the menu label. // string $label = `menuItem -q -l $itemName`; int $optionBox = `menuItem -q -isOptionBox $itemName`; if ($optionBox) { // Try to Use the "annotation" string if it exists // else use the menuItem name. $label = `menuItem -q -annotation $itemName`; if ("" == $label) $label = `menuItem -q -l $itemName`; } // If we have a good label then create a short overlay string // if ("" != $label) { string $buffer[]; int $numTokens = `tokenize $label $buffer`; if ($numTokens == 1) $imageOverlayLabel = `substring $label 1 3`; else if ($numTokens > 1) { for ($word in $buffer) { $imageOverlayLabel = $imageOverlayLabel + `substring $word 1 1`; } } // Now set the image overlay label menuItem -e -iol $imageOverlayLabel $itemName; } } } // Get the command for the shelf button. // string $subStr; string $command = `menuItem -query -dragMenuCommand $itemName`; if ("" == $command) { $command = `menuItem -query -command $itemName`; if (`menuItem -q -isCheckBox $itemName`) { if (`menuItem -q -cb $itemName`) { $subStr = "0"; } else { $subStr = "1"; } $command = `substitute "#1" $command $subStr`; } else if (`menuItem -q -isRadioButton $itemName`) { $subStr = "1"; $command = `substitute "#1" $command $subStr`; } } else { $command = eval($command); } // Get the double click command for the shelf button. // string $doubleClickCommand = `menuItem -query -dragDoubleClickCommand $itemName`; // Ask whether this is MEL or Python // string $sourceType = `confirmDialog -title "Maya" -ma "left" -message "Save menu item to shelf as type:" -button "MEL" -button "Python" -defaultButton "MEL" -cancelButton "MEL" -dismissString "MEL" `; // update the icon image if we have a Python script // if ($sourceType == "Python") $image = "pythonFamily.xpm"; // create the shelfButton // shelfButton -command $command -doubleClickCommand $doubleClickCommand -image1 $image -imageOverlayLabel $imageOverlayLabel -label `menuItem -q -label $itemName` -style `shelfLayout -q -style $currentShelf` -width `shelfLayout -q -cellWidth $currentShelf` -height `shelfLayout -q -cellHeight $currentShelf` -ann `menuItem -q -ann $itemName` -sourceType $sourceType; // -style "iconOnly"; } }