Skip to content

Instantly share code, notes, and snippets.

@dgovil
Created October 12, 2013 23:37
Show Gist options
  • Save dgovil/6956180 to your computer and use it in GitHub Desktop.
Save dgovil/6956180 to your computer and use it in GitHub Desktop.
Order Maya Shelves. The pref keyword is set to xxx but you can set it to whatever and it'll keep any shelves that start with it in the front
import maya.cmds as mc
import maya.mel as mm
gshelf = mm.eval("$temp = $gShelfTopLevel")
shelves = mc.tabLayout(gshelf,q=1,childArray=1)
sTotal = len(shelves)
pref = 'xxx'
sShelf = sorted([s for s in shelves if s.startswith(pref)]) + sorted([s for s in shelves if not s.startswith(pref)])
for i,shelf in enumerate(sShelf):
i += 1
sIndex = mc.tabLayout(gshelf,q=1,childArray=1).index(shelf)+1
mc.tabLayout(gshelf,e=1,moveTab=(sIndex,i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment