Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Adding a custom shelf & buttons?
  RSS 2.0 ATOM  

Adding a custom shelf & buttons?
Rate this thread
 
61414
 
Permlink of this thread  
avatar
  • J.D.
  • Posted: 27 October 2011 03:23 AM
  • Location: Berlin
  • Total Posts: 65
  • Joined: 17 November 2010 04:53 AM

Hey doods!

Ok, so Im trying to add a custom shelf for my scripts and I’ve found the necessary commands ( I think) however, im a little confused as to how exactly I pull this off. :S

I know I create a shelf with ‘addNewShelfTab’, but im not quite sure how I add the button - some tutorials say something about querying a global var that maya uses but so far everything I’ve read on this just confuses me even more :/

Your help’s appreciated!

Cheers,
JD



AutoWalk script out on CreativeCrash!
http://www.creativecrash.com/may...gins/animation/c/autowalk
Jeeves Simple Biped Rig:
http://www.creativecrash.com/maya/downloads/character-rigs/c/jeeves
Dload, test & share! Feedback very much appreciated!

Replies: 0
avatar
  • ldunham1
  • Posted: 27 October 2011 04:00 AM

its the shelfButton command.

string $label "label";
string $annotation "annotation";
string $command "command";
string $shelf "Custom";

shelfButton -rpt true -i1 "commandButton.png" -l $label -ann $annotation -c $command -p $shelf ;


Lee Dunham | Character TD
ldunham.blogspot.com

Replies: 1
/img/forum/dark/default_avatar.png

One more thing tho - how do I query the shelf to check whether or not it already exists?

Author: J.D.

Replied: 27 October 2011 08:27 AM  
avatar
  • ldunham1
  • Posted: 27 October 2011 10:51 AM

you can do a variety of things for that, checking the global vars would probs be best, will upload code 2moro. You could also check the user shelf dir and search for the shelf there too.



Lee Dunham | Character TD
ldunham.blogspot.com

Replies: 0
avatar
  • ldunham1
  • Posted: 28 October 2011 01:46 AM

you can use this to check whether shelf already exists, just enter shelf name into $shelf var

global string $gShelfTopLevel;
string $shelves[] = `tabLayout -q -childArray $gShelfTopLevel`;
string $shelf "Custom" ;
int $result false ;
for(
$i in $shelves)
{
    
if($i == $shelf)
    
{
        $result 
true ;
    
}
}
print $result ;


Lee Dunham | Character TD
ldunham.blogspot.com

Replies: 1
/img/forum/dark/default_avatar.png

thx!

I assume tho that I can’t have this run on startUp? I’ve tried putting it in the sourced init file for my script, but so far it’s just doing nothing :/

My source file looks like this:

global proc aw_init()
{
 source 
"aw_createShelf.mel";
 
source "aw_ctrlWin.mel";
 
source "aw_valWinA.mel";
 
source "aw_valWinB.mel";
 
source "aw_writeCtrls.mel";
 
source "aw_writeValA.mel";
 
source "aw_writeValB.mel";
 
source "aw_setLowCtrls.mel";
 
source "aw_setSpecAttr.mel";
 
source "aw_setSpine.mel";
 
source "aw_setArms.mel";
 
aw_createShelf;
}

aw_init
;

and the script for the shelf looks like urs, pretty much:

global proc aw_createShelf()
{
 
//State gVars used;
 
global string $gShelfTopLevel
 
//declare lVars necessary;
 
string $lVar_shelves[] = `tabLayout -q -childArray $gShelfTopLevel`;
 
string $lVar_shelfName "AutoWalk" ;
 
int $lVar_shelfExists false ;
 
//------


for($i in $lVar_shelves)
{
    
if($i == $lVar_shelfName)
    
{
        $result 
true ;
    
}
}
 
//Check if the shelf already exists; if so, check if the button already exists. If both are true, do nothing.
 //If the shelf is non-existant, add it, and the button. If only the button is missing, add only that.
 
if ($lVar_shelfExists false)
 
{
 addNewShelfTab 
"AutoWalk";
 
shelfButton -rpt true -i1 "commandButton.png" -"Start" -ann "Initiates the ctrl & value dialogue" -c aw_ctrlWin -"AutoWalk" ;
 
shelfButton -rpt true -i1 "commandButton.png" -"doHip&Feet" -ann "Keys hip & feet ctrls" -c aw_setLowCtrls -"AutoWalk" ;
 
shelfButton -rpt true -i1 "commandButton.png" -"doSpec" -ann "Keys special Attributes for the foot ctrls" -c aw_setSpecAttr -"AutoWalk" ;
 
shelfButton -rpt true -i1 "commandButton.png" -"doSpine" -ann "Keys the spine ctrls" -c aw_setSpine -"AutoWalk" ;
 
shelfButton -rpt true -i1 "commandButton.png" -"doArms" -ann "Keys the arm ctrls" -c aw_Arms -"AutoWalk" ;
 
}

}

It sources the scripts, and the global variables before that just fine, but on startup it just wont create the shelf (I dont have a shelf with that name either :P )

what am I missing?

Author: J.D.

Replied: 28 October 2011 02:46 AM  
avatar
  • J.D.
  • Posted: 28 October 2011 02:53 AM

Neever mind, missed a “=” in the if conditions <.<

Thx for your help! :D



AutoWalk script out on CreativeCrash!
http://www.creativecrash.com/may...gins/animation/c/autowalk
Jeeves Simple Biped Rig:
http://www.creativecrash.com/maya/downloads/character-rigs/c/jeeves
Dload, test & share! Feedback very much appreciated!

Replies: 1
/img/forum/dark/default_avatar.png

Ok, nevermind the “nevermind” bfore, I think I messed up my shelves :D

Now all my shelves are gone and it tells me that “AutoWalk” is not a unique name (when its autmatically sourcing at startup) and if I execute again it says
Error: file: C:/Program Files/Autodesk/Maya2011/scripts/others/addNewShelfTab.mel line 76: Object’s name ‘spacingSeparator’ is not unique.

sooo...how much have I messed up my maya? :D

Author: J.D.

Replied: 28 October 2011 03:02 AM  
avatar
  • ldunham1
  • Posted: 28 October 2011 03:21 AM

seems to be because your not changing the $lVar_shelfExists var. when you check to see whether shelf exists, you declare $result when you need to alter the $lVar_shelfExists instead.

that should fix the unique name issue, which i think should work no probs now (does here!).



Lee Dunham | Character TD
ldunham.blogspot.com

Replies: 1
/img/forum/dark/default_avatar.png

and again Im starting to doubt my intelligence. Jeesh.
thank you again ;D

Author: J.D.

Replied: 28 October 2011 03:24 AM