Mel - Maya Embedded Language

Sliders update a given value without having to type it in. Consult the maya help menu to see more options associated with sliders.

//create a simple slider
//first slider is default
//second slider constrains the slider values

    string $window = `window -title "floatSliderGrp Example"`;
    floatSliderGrp -label "Group 1" -field true;
    floatSliderGrp -label "Group 2" -field true
    	-minValue -10.0 -maxValue 10.0
    	-fieldMinValue -100.0 -fieldMaxValue 100.0
    	-value 0;
    showWindow $window;

//create a simple placement randomizer using slider values

if (`window -exists intSliderWin`)
	deleteUI intSliderWin;
	windowPref -remove intSliderWin;

window -widthHeight 400 250 intSliderWin;
columnLayout -width 400;
text  -label "How Many Objects do you Want?";
intSliderGrp -label "Number of Objects" -field true slider1;
text  -label "What will the variation limits be?";
intSliderGrp -label "MinX" -field true -min -100 -max 100 sliderXMin;
intSliderGrp -label "MaxX" -field true -min -100 -max 100  sliderXMax;
intSliderGrp -label "MinY" -field true -min -100 -max 100  sliderYMin;
intSliderGrp -label "MaxY" -field true -min -100 -max 100  sliderYMax;
intSliderGrp -label "MinZ" -field true -min -100 -max 100  sliderZMin;
intSliderGrp -label "MaxZ" -field true -min -100 -max 100  sliderZMax;
button -label "Do the Doing" -command "Do();";

showWindow intSliderWin;

proc Do()
// error Checking
// too many pieces of geometry
string $checksafe[] = `ls -sl`;
int $checker = size($checksafe);
if ($checker > 1)
{error("please select only one Item");}
//not geometry selected
for ( $checksafes in $checksafe ) 
	if ( `nodeType $checksafes` != "transform" ) 
		error ("please select geometry only");
int $duplicated = `intSliderGrp -query -value slider1`;
for ($i = 0; $i < $duplicated; $i++)
	//select Selected
	string $obj[] = `ls -sl`;
	//query slider values	
	int $minX =`intSliderGrp -query -value sliderXMin`;
	int $maxX =`intSliderGrp -query -value sliderXMax`;
	int $minY =`intSliderGrp -query -value sliderYMin`;
	int $maxY =`intSliderGrp -query -value sliderYMax`;
	int $minZ =`intSliderGrp -query -value sliderZMin`;
	int $maxZ =`intSliderGrp -query -value sliderZMax`;
	//make them random
	float $randX = rand($minX, $maxX);
	float $randY = rand($minY,$maxY);
	float $randZ = rand($minZ,$maxZ);
	//move selected
	move ($randX)($randY)($randZ) $obj;
	//duplicate Selected
	duplicate $obj;	


//create a color slider field.

window -title "Attr Field Slider Groups";
    	string $objName = `shadingNode -asShader phong`;
    	attrColorSliderGrp -at ($objName+".color");