// =========================================================================== // 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. // =========================================================================== // // // // // // // scriptToShelf (string $label, string $script, int $isMEL) // // // None. // // // Creates a shelf item on the currently active shelf that will // execute the given script of the given type. // // // string $label The label to give the new shelf item. // string $script The script to be executed when the shelf item is clicked. // int $isMEL whether the script is of type MEL or Python // // // scriptToShelf ("Sel", "select -all", true); // // global proc scriptToShelf (string $label, string $script, int $isMEL) { global string $gShelfTopLevel; if (`tabLayout -exists $gShelfTopLevel`) { string $currentShelf = `tabLayout -query -selectTab $gShelfTopLevel`; setParent $currentShelf; string $sourceType = ($isMEL ? "mel" : "python"); // TODO: get real python shelf command button icon string $sourceIcon = ($isMEL ? "commandButton.png" : "pythonFamily.png"); // Create the shelf button on the current shelf. // Give it the default MEL script icon, // and set the short label too. // shelfButton -command $script -sourceType $sourceType -label $label -annotation $script -imageOverlayLabel $label -image1 $sourceIcon -style `shelfLayout -query -style $currentShelf` -width `shelfLayout -query -cellWidth $currentShelf` -height `shelfLayout -query -cellHeight $currentShelf`; } }