PDA

View Full Version : Help programming a custom Maya toolbox please!


NocturnalTrance
05-23-2007, 04:55 PM
Hello fellow nerds :)

I'm into all the MEL scripting and such, but i haven't been able to program a panel/pane like the standard toolbox in Maya, you know, the kinda panel/pane that sticks to the main Maya window like all the standard UI items of Maya does (toolbox, shelf, channelbox, etc.). I've been wanting to gather all my code and tools i've programmed into one single MEL script under a panel/pane as described. But, unfortunately, since i can't do it in MEL scripting, i'll have to do it as a C++ plug-in (unless someone knows how to program such a panel/pane in MEL, i'd be grateful to hear how to do it). So, i was wondering if anyone could get me up and running with the basics of programming such a panel/pane in a C++ plug-in (.mll), that i can build on. Please help, when i've gathered everything into this all-in-one plug-in or MEL solution, i'll share it with others and constantly keep new functions coming to it.

-Vormav-
05-23-2007, 11:47 PM
You usually can't do this with the API. You can easily add your own floating windows, but you can't do controls that are embedded the way you're suggesting.
If you look around at http://secretlevel.com/ , they have an old paper (~2003/2004) where they cover an MFC hack for pulling something like this off. I've tried it myself, and it does work. BUT, it uses MFC, and so only works in Windows, and it can be a pretty nasty trick to figure out.
Honestly, you're far better off just finding some way, *any* way, of doing your panel just with MEL. You could create a dummy node, and use it to embed the gui in the attribute editor (with the aescript). Or if you're on an older version of Maya, the embedded webbrowser may be an even better approach (I don't know why they removed that in Maya 8...). Aside from that... just learn to live with a floating window!

NocturnalTrance
05-24-2007, 07:12 AM
I know it's possible somehow .. look at the NEX plug-in for Maya, it has that kind of toolbox window.. So it must be possible someway or another ..

mhovland
05-24-2007, 12:23 PM
I have written my own tool boxes that are imbedded in the Maya interface. I will look up the scripts at the office, and let you know where you need to start digging.

It isn't exactly easy, but it ain't that hard, either.

NocturnalTrance
05-24-2007, 03:02 PM
I have written my own tool boxes that are imbedded in the Maya interface. I will look up the scripts at the office, and let you know where you need to start digging.

It isn't exactly easy, but it ain't that hard, either.


oh boy, thanks alot .. now remember, MEL is something i know, C++ is something i'm only starting to mess with, so please make it understandable for a newbie C++ programmer ... if it is C++ ? .. dunno, you didn't mention that :P

Robert Bateman
05-24-2007, 07:48 PM
{
setParent ChannelsLayersPaneLayout;
paneLayout -e -configuration "horizontal3" ChannelsLayersPaneLayout;
$name=`button -label "Howdy Do!!"`;
paneLayout -e -setPane $name 3 ChannelsLayersPaneLayout;
};

you will need to be a bit cleverer than that though, but it's a starting point. Just do some find in files on the scripts dir for ChannelsLayersPaneLayout and start hunting. As i recall it all comes down to the showChannelsLayers command, which you will need to modify slightly to get a new pane in there working properly. At least, that's what i did anyway.

NocturnalTrance
05-24-2007, 07:59 PM
{
setParent ChannelsLayersPaneLayout;
paneLayout -e -configuration "horizontal3" ChannelsLayersPaneLayout;
$name=`button -label "Howdy Do!!"`;
paneLayout -e -setPane $name 3 ChannelsLayersPaneLayout;
};

you will need to be a bit cleverer than that though, but it's a starting point. Just do some find in files on the scripts dir for ChannelsLayersPaneLayout and start hunting. As i recall it all comes down to the showChannelsLayers command, which you will need to modify slightly to get a new pane in there working properly. At least, that's what i did anyway.


I'm on my mac atm, don't have Maya on it for the reason of bad graphics card, i'll try and put it into my Maya and see what it does when i get it back from a friend.. I haven't seen the ChannelsLayersPaneLayout command before though, might just do the trick .. but i'll have to try it out.. if i can make the actual pane in clean MEL, no C++, would definitely be a plus, so i don't have to learn C++ before i get my tool going :) thanks buddy i'll have a look at it :)

NocturnalTrance
05-25-2007, 03:53 PM
{
setParent ChannelsLayersPaneLayout;
paneLayout -e -configuration "horizontal3" ChannelsLayersPaneLayout;
$name=`button -label "Howdy Do!!"`;
paneLayout -e -setPane $name 3 ChannelsLayersPaneLayout;
};


I just tried this code out Robert .. it's close, but i need it to be either a brand new panel, not an addition to one of the existing, or even better, just rewrite the code of the actual Toolbox in Maya.. I mean, i NEVER use it, i have actually almost never my UI elements turned on, not even the main menubar or titlebar, it's just a filled screen with my modeling pane/panes, and then i use the hotbox and marking menus to navigate ..

I've tried rewriting the code of the actual toolbox, and found two different results for two different methods so far:

1 - Back up the script, delete every line of code in the one read by Maya. This results in a toolbox showing up with nothing in it, Maya doesn't complain about it. But when i tried to write some simple code into it like for instance a layout, a button and reload Maya, it still shows up empty. Or, of course, won't load up Maya, but just shows the Script Editor if there is an error in the script.

2 - Thinking the script might relay on other parts of Maya, i kept all the procedures and stuff that wasn't UI related for the script. This will still make it show up in Maya, but if you do one line wrong, that Maya doesn't "expect" it seems, it will just show the Script Editor and not load Maya.


Now, proving that it can be altered and still work, there might be somebody hardcore coder out there of you guys, that knows how to alter it so the content written will show up too, not just an empty toolbox. If anyone can break that one, i'll be able to take it from there and make a kick-*** MEL for us all. Like, taking a useless part of Maya and turning it into something useful ;) heh ..

well, Robert, it was close, veeery close, i liked to see that pop up in there .. "howdy do" ... haha ... lovely :)


Thanks for helping out guys, i appriciate it :)

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;

NocturnalTrance
05-27-2007, 11:55 AM
Wow ... you are good .. thanks :)

is it possible to resize the toolbox too? or will it resize according to the layout in it ? .. on my mac again, but i can what this code would do, haven't tried it yet though .. will do later today :)

NocturnalTrance
05-27-2007, 04:51 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;



I just tried it, woot! looks like JUST what i wanted .. thanks alot guys for all your help, i'll try to make a great MEL for changing the toolbox into something useful :)

thanks again guys :)

CGTalk Moderation
05-27-2007, 04:51 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.