Modifying Maya UI

Hi there,

thought I’d through a question out about modifying Maya’s native UIs.

For example, I’d like to add a button next to the ‘Create new layer’ button in the Layer Editor window.
I did a search for the string in Maya’s install directory, though nothing with much help appeared to showed up.

Most of Maya’s internal mel will be in C:\Program Files\Autodesk\Maya2008\scripts\

I found Create a new layer in startup\layerEditor.res.mel

displayString -replace -value “Create a new layer” m_layerEditor.kCreateNewLayer;

and then in layerEditor.mel it’s where they add the button

line 340

//	Button for creating new layers.
//
$emptyDispLayer = `symbolButton -image "newLayerEmpty.xpm"
	-annotation (uiRes("m_layerEditor.kCreateNewLayer")) emptyDispLayer`;
//	Tab layout with two children. One for display layers, the other
//	for render layers.
//

Hope it helps

You should be able to make a modified layerEditor.mel and put it in your script path and once it sources it should overwrite Maya’s internals

Yep, that helped… thanks.

As a test, was able to edit the annotation for the emptyDispLayer symbolButton…

Though looks like it’s not as easy to edit the preceding formLayout $form because it’s not been given a name, so it’s difficult to grab…? $form = formLayout.

Ideally I’d want to create a second symbolButton next to the existing emptyDispLayer button.

Hey, not sure how helpful this is but I had similar issues when customising the timeSliderMenu in that the some of the UI object names were not fixed. It sounds similar to your issue - the formLayout will have a name, it’s finding what it is that’s the problem.

I was adding a menu item to the popup menu when right clicking on the timeline.
A trawl through the maya scripts revealed that the object name for its parent - the playBackSlider is stored in a global variable, but that the object name for the menu is consistent. I could therefore generate my complete UI object string by;

global string $gPlayBackSlider;
string $tokenized[];
tokenize $gPlayBackSlider "|" $tokenized;
string $popUpParent = $tokenized[0];
for ($counter = 1; $counter < (`size($tokenized)`-2);$counter++)
	$popUpParent = (($popUpParent)+"|"+($tokenized[$counter]));

$popUpParent = (($popUpParent)+"|TimeSliderMenu");
print $popUpParent;

I’ll try and have a go at what you’re trying to do when I get a spare moment, hopefully the above info might get you a bit further but I’ve found that the way the UI is constructed to be sometimes quite inconsistent.

Will this thread be of help?

http://forums.cgsociety.org/archive/index.php/t-499444.html

Robert Bateman
05-25-2007, 06:08 PM
You mean like this?

// kill all GUI items under the toolbox form
deleteUI formLayout -q -ca $gToolboxForm;

// and replace with your own stuff
setParent $gToolboxForm;
$b = button -label "HowdyDo!!";
formLayout -edit
-attachForm $b “top” 0
-attachForm $b “left” 0
-attachForm $b “bottom” 0
-attachForm $b “right” 0
$gWorkAreaForm;

Some other useful globals to do pretty much the same thing…

global string $gMainWindow;
global string $gMainWindowForm;
global string $gStatusLineForm;
global string $gShelfForm;
global string $gWorkAreaForm;
global string $gMainPane;
global string $gToolboxForm;
global string $gTimeSliderForm;
global string $gPlaybackRangeForm;
global string $gCommandLineForm;
global string $gHelpLineForm;
global string $gAttributeEditorForm;
global string $gToolSettingsForm;
global string $gChannelsLayersForm;
global string $gMayaLiveControlForm;

Nice list of global variables, very usefull!

Guys,

thanks for your replies to this post.

I’ve had zero time to look at this last week, but I’ve just checked out a couple of lines and managed to do exactly what I wanted.


// find the layout for symbolButtons
string $displayLayerTabChildren[] = `menuBarLayout -q -childArray DisplayLayerTab`;

// setParent to layout
setParent $displayLayerTabChildren[0];

// create new symbolButton control
$layerCompsButton = `symbolButton -width 26 -height 26 -image $layerCompsImage
		-annotation "Layer Compositions" layerCompositions`;

// arrange symbolButton to the left of existing 'emptyDispLayer' button
formLayout -edit
		-attachForm $layerCompsButton "top" 1
		-attachControl $layerCompsButton "right" 1 emptyDispLayer
		-attachNone $layerCompsButton "bottom"
		-attachNone $layerCompsButton "left"
		
		$displayLayerTabChildren[0];

This is the result: