heres the code i have so far:
global proc resortSel()
{
string $userSel[] = `ls -sl`;
for ($each in $userSel)
{
reorder -b $each;
}
sort $userSel;
}
window -title "Outliner Tools" -width 250 -height 200;
columnLayout -adjustableColumn true;
button
-label "Move to First"
-command "reorder -front;";
button
-label "Move to Last"
-command "reorder -back;";
button
-label "Move Up"
-command "reorder -relative 1;";
button
-label "Move Down"
-command "reorder -relative -1;";
button
-label "Reorder base on Selection";
-command "resortSel;";
showWindow;
When I run this code, I get this
// Error: -command "resortSel;";
//
// Error: Syntax error //
Can anyone please point out what I did wrong and how to fix. Thank you
Replies
button -label "Reorder base on Selection"; -command "resortSel;";After "Reorder base on Selection" you have a semicolon. Therefore maya doesn't recognize the following line as a member of the button setting definition. You should display the line number of the errors in your script editor, this would help you find the location of your errors.Also, you don't need to specify the semicolon inside the command quote (" ") if you are only calling one function. This would help you read a bit better your script and avoid any confusion.
glboal proc resortNum() { string $sel[] = sort(`ls -sl`); for ($eachNode in $sel) { reorder -b $eachNode; } } global proc resortName() ////This bottom portion with the promptDialog is sampled from another site//// { string $text; string $result = `promptDialog -title "Select Object" -message "Enter Name:" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`; if ($result == "OK") { $text = `promptDialog -query -text`; } select -r ("*" + $text + "*"); string $saSel[] = `ls -sl -l -fl`; string $saGeo[] = `filterExpand -sm 12 $saSel`; select -r $saGeo; if ($result = "OK") { resortNum; } } global proc outlinerToolsv1() { if (`window -exists outlinerTools`) deleteUI outlinerTools; } outlinerToolsv1; window -title "Outliner Tools" -width 250 -height 200 outlinerTools; columnLayout -adjustableColumn true -rowSpacing 8; button -label "Move to First" -align "center" -command "reorder -front;"; button -label "Move to Last" -align "center" -command "reorder -back;"; button -label "Move Up" -command "reorder -relative -1;"; button -label "Move Down" -align "center" -command "reorder -relative 1;"; button -label "Reorder base on Selection" -command "resortSel;"; button -label "Reorder Numerically" -align "center" -command "resortNum;"; button -label "Reorder by Name" -align "center" -command "resortName;"; radioButtonGrp -numberOfRadioButtons 2 -label "Select type" -labelArray2 "InsideGroup" "Scene" ///I assume this is where I put the code for selecting the default button, but not sure what to put /// showWindow outlinerTools;or run the radioButtonGrp command in edit mode and use the -select flag if you want to do it after the control is defined.
radioButtonGrp -numberOfRadioButtons 2 -select 1 -label "Select type" -labelArray2 "InsideGroup" "Scene" ;would select the first radioButton on creation.new question: is it possible to find where a node is located in Outliner, like the number order? I have search through all the maya command reference and have found nothing in regards to that.
global proc reorderinPlace() { string $unsortList[]=`ls -sl`; string $sortList[]= `sort($unsortList)`; if (`gmatch $unsortlist "*[0-9]"`) //To check if object has number suffix { warning "please rename object with number suffix"; break; //exit procedure if there is no number suffix } else { for ($count=0; $count<=size($unsortList); $count++) { int $unsortNum= `match "[0-9]+$" $unsortList`; //extract number from unsorted list int $sortNum= `match "[0-9]+$" $sortList`;//extract number from sorted list $reorderNum[]= 0; if ($unsortList != $sortList) $reorderNum[]= `$unsortNum - $sortNum`;//Getting the relative reorder value reorder -r $reorderNum $unsortList } } print "Objects are sorted"; }