I have a mel script that I use if my graph editor has a visual bug where it appears blank/empty. What the script does is tears off the graph editor, closes it, and then runs the command to go to my saved panel layout called "Animation"
It works perfectly when run through the script editor, or the Mel box at the bottom of Maya, but when I save it as a button on my shelf, it will tear off the graph editor and close it, but won't run the panel layout part of the code.
I'm stumped, so if anyone knows how to get it to work as a shelf button that would be great!
if (`window -q -ex graphEditor1Window`)
deleteUI graphEditor1Window;
else
tearOffPanel "Graph Editor" "graphEditor" true;
deleteUI graphEditor1Window;
setNamedPanelLayout "Animation";
I have tried saving it as its own .mel file and calling it, but that hasn't worked. Nor has trying different ways of calling it through the shelf button
I suppose you always want to set the layout to "Animation" so you should reformat your code like this:
This way the graph editor window is always deleted and then always your layout is applied. This works fine for me as shelf button or as script in the script editor.