The easiest way is to query a global variable (that can be found in the many startup scripts) but more often then not, a global variable for that specific menu you want will not exist. In that case, we need to do some digging....
In this example, we are looking for the "Channels" menu in the Channel Box. We can easily find out the name of that menu by doing an "Echo All Commands" and opening it ; Maya will spit out it's name. But we really don't want to hard code that.... so instead build a string consisting of its name.
In this case the menu name is:
MayaWindow|mayaMainWindowForm|formLayout3|formLayout11|formLayout32|
formLayout33|ChannelsLayersPaneLayout|formLayout36|menuBarLayout1|menu1 ;
In order to do this,we need to start with a global variable. In this case use $gChannelsLayersForm, a global variable that is a parent layout of the Channel Box "Channels" menu.
String $menu = `print $gChannelsLayersForm`;//Result: MayaWindow|mayaMainWindowForm|formLayout3|formLayout11|formLayout32|
formLayout33
In above example we get part of the name but not the entire name, so continue querying its children.
string $menu_1[] = `formLayout -q -ca $gChannelsLayersForm`;
// Result: formLayout35 ChannelsLayersPaneLayout formLayout40 //
We want the 2nd index (ChannelsLayersPaneLayout ) so need to find out it’s type before querying it to find its children:
objectTypeUI $menu_1[1]
// Result: paneLayout //
so we use paneLayout command for the next one....
string $menu_2[] = `paneLayout -q -ca ($gChannelsLayersForm + "|" +$menu_1[1])`;
// Result: formLayout36 formLayout37 //
objectTypeUI $menu_2[0]
// Result: formLayout //
so we use formLayout command for the next one.... so on and so forth until you get the name of the full menu!
thanx,.. but what if i decided to add new button to maya playback control? for example i need to add interactive playback btn.
Posted by: zax | 02/08/2010 at 10:18 PM