Created
August 31, 2024 07:55
-
-
Save justsh/b99309c6b54f840e1bb80a32f8f00d5b to your computer and use it in GitHub Desktop.
make a new maya shelf (solo projects only). uses a template file in $MY_PROJECT/aux if it exists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ -z "$1" ]; then | |
| printf "%bPlease pass a name for the new shelf (e.g. model_tools)%b\n" "${FG_RED}" "${NORMAL}" | |
| exit 1 | |
| fi | |
| name=$1 | |
| generate_shelf_empty() { | |
| cat << EOF > ${new_shelf} | |
| global proc shelf_${1} () { | |
| global string \$gBuffStr; | |
| global string \$gBuffStr0; | |
| global string \$gBuffStr1; | |
| } | |
| EOF | |
| } | |
| MY_MAYA_SHELVES_DIR="${MY_PROJECT}/custom/maya/shelves" | |
| template_shelf="${MY_PROJECT}/aux/maya/shelf_Template.mel.py" | |
| new_shelf="${MY_MAYA_SHELVES_DIR}/shelf_${name}.mel" | |
| # Prefer a template shelf in $MY_PROJECT/aux, generate new if it does not exist | |
| if [ ! -f "${new_shelf}" ]; then | |
| if [ -f "${template_shelf}" ]; then | |
| cp ${template_shelf} ${new_shelf} && \ | |
| pyp "lose('//') | p.format(Name=\"$name\")" < "${template_shelf}" > ${new_shelf} | |
| else | |
| generate_shelf_empty $name | |
| fi | |
| else | |
| printf "%berror: A shelf named %s already exists, exiting...%b\n" "${FG_RED}" "$name" "${NORMAL}" | |
| exit | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // -*- mode: MEL -*- | |
| global proc shelf_{Name} () {{ | |
| global string $gBuffStr; | |
| global string $gBuffStr0; | |
| global string $gBuffStr1; | |
| shelfButton | |
| -enableCommandRepeat 1 | |
| -enable 0 | |
| -width 35 | |
| -height 35 | |
| -manage 1 | |
| -visible 1 | |
| -preventOverride 0 | |
| -annotation "spacer" | |
| -enableBackground 0 | |
| -align "center" | |
| -label "Spacer" | |
| -labelOffset 0 | |
| -font "plainLabelFont" | |
| -overlayLabelColor 0.8 0.8 0.8 | |
| -overlayLabelBackColor 0 0 0 0.25 | |
| -image "vacantCell.png" | |
| -image1 "vacantCell.png" | |
| -style "iconOnly" | |
| -marginWidth 1 | |
| -marginHeight 1 | |
| -sourceType "mel" | |
| -commandRepeatable 1 | |
| ; | |
| shelfButton | |
| -enableCommandRepeat 1 | |
| -enable 1 | |
| -width 35 | |
| -height 35 | |
| -manage 1 | |
| -visible 1 | |
| -preventOverride 0 | |
| -annotation "Create a new button on the {Name} Shelf" | |
| -enableBackground 0 | |
| -align "center" | |
| -label "CreateNewButton" | |
| -labelOffset 0 | |
| -font "plainLabelFont" | |
| -imageOverlayLabel "btn+" | |
| -overlayLabelColor 0.8 0.8 0.8 | |
| -overlayLabelBackColor 0 0 0 0.8 | |
| -image "defaultSingleLayout.png" | |
| -image1 "defaultSingleLayout.png" | |
| -style "iconOnly" | |
| -marginWidth 1 | |
| -marginHeight 1 | |
| -command "import pymel.core as pm\n\nbtn = pm.shelfButton(\n\tlabel=\"NewButton\",\n\tparent=\"{Name}\", # SET ME TO THE CURRENT SHELF NAME \n\timage=\"defaultSingleLayout.png\", \n sourceType=\"python\",\n command=\"import pymel.core as pm\",\n\tannotation=\"\",\n\toverlayLabelBackColor=[0, 0, 0, 0.8],\n imageOverlayLabel=\"#####\")" | |
| -sourceType "python" | |
| -commandRepeatable 1 | |
| ; | |
| shelfButton | |
| -enableCommandRepeat 1 | |
| -enable 1 | |
| -width 35 | |
| -height 35 | |
| -manage 1 | |
| -visible 1 | |
| -preventOverride 0 | |
| -annotation "Create a new spacer on the {Name} Shelf" | |
| -enableBackground 0 | |
| -align "center" | |
| -label "CreateNewSpacer" | |
| -labelOffset 0 | |
| -font "plainLabelFont" | |
| -imageOverlayLabel "spcr+" | |
| -overlayLabelColor 0.8 0.8 0.8 | |
| -overlayLabelBackColor 0 0 0 0.8 | |
| -image "defaultSingleLayout.png" | |
| -image1 "defaultSingleLayout.png" | |
| -style "iconOnly" | |
| -marginWidth 1 | |
| -marginHeight 1 | |
| -command "import pymel.core as pm\n\nbtn = pm.shelfButton(\n\tlabel=\"Spacer\",\n\tparent=\"{Name}\",\n\timage=\"vacantCell.png\",\n\tenable=False,\n\tannotation=\"spacer\")" | |
| -sourceType "python" | |
| -commandRepeatable 1 | |
| ; | |
| }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment