Another Mel question, for the sake being efficient

I currently have a script as a WIP, and its all going well since i got the first part to work with selection, and I’m moving onto trying to get the objects to triangulate, Quadrangulate or Do nothing to the meshes.

the issue i have is that in trying to add these together it seems like how I’m working is incredibly inefficient I was hoping you guys could take a look at my script and give me some pointers in making this script work better, and easier for adding other functions within it.

-as always thanks a ton for your help, much apperciated

global proc Kc_Lowres()
{

if(window -q -exists "kc_Window")
deleteUI -window “kc_Window”;
string $window = window -title "Kc_Poly_Reduction" -tlb 1 "kc_Window";
window -e -width 100 -height 250 $window;
columnLayout;
columnLayout;
// button -label “Whole Scene” -w 107 -c “WholeScn()”;
// button -label “Selected Objects” -w 107 -c “SelectObj()”;
radioButtonGrp -nrb 2 -la2 “Whole Scene” “Selected” -sl 1 radioButtonGrp_setSelectionMethod;
radioButtonGrp -nrb 3 -la3 “Triangulate” “Quadrangulate” “Do Nothing”-sl 1 radioButtonGrp_georeduction;
button -label “smooth” -w 215 -c “smooth()”;
showWindow “kc_Window”;
}

global proc smooth()
{
string $selectall[] = ls -type "mesh";
string $selectobjects[] = ls -sl;
{
int $sel_mode = radioButtonGrp -q -sl radioButtonGrp_setSelectionMethod;
if($sel_mode == 1)
{
{
select $selectall;
}
for( $items in $selectall)
{
polySmooth -mth 0 -dv 1 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -peh 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $items;
}
}
else

select $selectobjects;
}

for( $items2 in $selectobjects)
{
polySmooth  -mth 0 -dv 1 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -peh 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $items2;
}

}

/*
int $sel_cleanupmode = radioButtonGrp -q -sl radioButtonGrp_georeduction;
if($cleanupmode == 1)
{
polyTriangulate -ch 1 pPipe11;
}
if($cleanupmode == 2)
{
polyQuad -a 30 -kgb 0 -ktb 0 -khe 0 -ws 0 -ch 1 pPipe11;
}

else

//nothing

In terms of making it more efficient, you could split up the smooth function into multiple functions. It currently looks like a long process where you first decipher the radio buttons, then call each feature based on that. If you ever scaled up the features on the script, it would be a lot of nasty cut-and-paste work.

If the smooth function became a wrapper that just read the radio buttons and called other smaller functions that did the work, you might find it easier to manage.

thanks for the reply however how do you create a wrapper. I understand the concept however the execution of the script got me mindboggled :no: .

I figure its something like this
//////////////////////////////////
global proc executionfunction()

{
execute action1;
execute action2;
execute action3;
}

global proc action1()
{
blah;
}
global proc action2()
{
blah blah;
}
global proc action3()
{
blah blah blah;
}
/////////////////////////////////////////
however can you put procs into other procs and strings into other strings.

0-0
seems like I’m more confused then when I started lol.