PDA

View Full Version : help with mel


slothuus
07-06-2007, 03:13 PM
hey guys


i could really use some help with this


the thing i want to do is to save out all the buttons i the shelfLayout into a file
and load all the buttons into the shelfLayout again.


i just started using mel soo iam still little newbie


hope you can help me thanks


//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////


if(`window -exists NsShelftwindow`)
deleteUI NsShelftwindow;
if( `windowPref -exists NsShelftwindow` )
windowPref -r NsShelftwindow;

window -w 300 -h 300 -t "NsShelftwindow"
-titleBar 1 -mnb 1 -mxb 1 -mb 1
-tlb 0 -sizeable 1 NsShelftwindow;


frameLayout -w 200 -l "Selction"
-la "top" -bs "in"
-cll 1 -cl 1 frameAnimSelcSet;



paneLayout -w 200 -h 200 -aft 5 -st 5
-configuration "vertical2" -api 1
-paneSize 1 90 50
-paneSize 2 38 50 ;



NS_ShelfSelc;
setParent..;
setParent..;
NS_ShelfSelcButtonsgrid;


//--------------------------------------------
//--------------------------------------------
//--------------------------------------------




global proc NS_ShelfSelc (){



shelfTabLayout -h 200
-image "smallTrash.xpm"
-imageVisible true mainShelfTab;

shelfLayout anim;

}

//--------------------------------------------
//--------------------------------------------
//--------------------------------------------

global proc saveShelfButtom(){
string $tempDir = ` fileDialog -m 1`;
saveShelf "anim" ($tempDir + "");
}



global proc NS_ShelfSelcButtonsgrid(){

gridLayout
-cr 0 -aec 1 -ag 0
;

button -l "Save" -align "center"
-c "saveShelfButtom";

button -l "Load" -align "center"
-c "loadShelfCustom";

}


//--------------------------------------------
//--------------------------------------------
//--------------------------------------------
global proc loadShelfCustom(){
loadNewShelf"";
}

//--------------------------------------------
//--------------------------------------------
//--------------------------------------------
showWindow NsShelftwindow;

rtngkllr
07-06-2007, 07:05 PM
Saving buttons on shelves is handled by the maya interface. You need not go into scripting to accomplish this.

You can easily make a new shelf, add your buttons, then select "save all shelves". Access to these commands are to the left of the shelf. It's that little arrow that points downward: click on it.

Cheers

slothuus
07-06-2007, 09:03 PM
yes i know that... iam not that must off a newbie

this is a custom shelf.... i dont want maya's own sheft stuff...

iam making a tool box with some selection stuff that means that i have
my own shelf layout and want to save the thing in the layout to file
so a other person can use them


best regards

Nicolai slothuus

rtngkllr
07-07-2007, 12:47 AM
right, this should get you started...

string $items[] = `shelfLayout -q -ca anim`;
$fileId = `fopen "C:\\test.txt" "w"`;
for( $item in $items )
{
string $command = `shelfButton -q -c $item`;
fprint $fileId ($command + "\n");
}
fclose $fileId;

CGTalk Moderation
07-07-2007, 12:47 AM
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.