hello all,
I hope my question isn't too naive, I'm having terrible trouble with a mel script.
These procedures are all contained in a file named buildGeoSphere.mel:
== buildGeoSphere.mel ========================================================================
// Build a geodesic sphere by iteratively subdividing an icosahedron
global proc buildGeoSphere (float $radius, int $iterations) {...}
// Provide a graphical interface to buildGeoSphere
global proc buildGeoSphereUI (){
if( `window -exists buildGeoUI` != 1 ){
string $myWin = `window -title "GeoSphere Options"
-rtf true
-sizeable false
-maximizeButton false buildGeoUI`
;
columnLayout;
$radiusGrp = `floatSliderGrp -value 1 -field true -min 0 -max 10 -fieldMinValue 0 -fieldMaxValue 1000000000 -label "Radius"`;
$iterationsGrp = `intSliderGrp -value 0 -field true -min 0 -max 10 -fieldMinValue 0 -fieldMaxValue 1000000000 -label "Iterations"`;
print ("radiusGrp = " + $radiusGrp);
print ("iterationsGrp = " + $iterationsGrp);
rowLayout -nc 3 -columnAttach3 "both" "both" "both" -columnAlign3 "center" "center" "center";
- button -width 130 -label "Create" -command "buttonAction(1, $radiusGrp, $iterationsGrp)";
-
button -width 130 -label "Apply" -command "buttonAction(2, $radiusGrp, $iterationsGrp)";
button -width 130 -label "Close" -command "closeUI();";
showWindow $myWin;
}
}
// Close the graphical interface
proc closeUI (){...}
// Perform button actions
proc buttonAction (int $whichButton, string $r_field, string $i_field){...1}
== end of buildGeoSphere.mel =================================================================
Now when I source and run my script in Maya: (source buildGeoSphere; buildGeoSphereUI;), I encounter the following terrible and inexplicable errors:
a) nothing works unless all the procs are global
on the lines marked by * Maya complains that $radiusGrp and $iterationsGrp are undefined, even though there are clearly defined just three lines above.
Incidentally the print statements work, and output the following:
radiusGrp = buildGeoUI|columnLayout2|floatSliderGrp1
iterationsGrp = buildGeoUI|columnLayout2|intSliderGrp1
and the whole layout is visible, sliders, buttons and all.
I would appreciate help on both accounts, how can I avoid making all the procs global and why are my variables coming up undefined when they're clearly defined?
Warmest Regards,
Alex Kessaris