-cw3 60 165 10
-ct3 "left" "both" "left"
browseTFG;
showWindow $window;
5.8.3 Code and Comments
Note: In some of the code, the formatting is a bit strange due to the limitations
of the book’s page width.
//======================================================================
// km_debrisCreator generates the UI
//======================================================================
global proc km_debrisCreator(){
string $path = `getSceneDir`;
if (`window -exists km_debrisCreatorUI`)
deleteUI km_debrisCreatorUI;
window -wh 295 500 -mxb 0 -t "km_debrisCreator" -s 1 km_debrisCreatorUI;
menuBarLayout;
menu -label "Edit";
menuItem -l "Reset to defaults"
-c "resetUI()"
;
columnLayout -adj 1 mainCol;
//########### FRAME ONE: Debris specs ###########
frameLayout -l "Debris Specs "
-collapsable 1
-borderStyle "etchedIn"
specsFrame;
columnLayout -adj 1 specsCol;
intSliderGrp -label "Amount"
-ann "The number of pieces"
Hands-On MEL Coding: km_debrisCreator
147
Chapter 5
-cw3 60 50 10
-ct3 "left" "both" "left"
-field true
-minValue 1
-maxValue 100
-fieldMinValue 1
-fieldMaxValue 100
-value 10
numSlider;
floatSliderGrp -label "ScaleMin"
-ann "The scale of the smallest piece"
-cw3 60 50 10
-ct3 "left" "both" "left"
-field true
-minValue .1
-maxValue 100.0
-fieldMinValue .1
-fieldMaxValue 100.0
-value .5
scaleMinSlider;
floatSliderGrp -label "ScaleMax"
-ann "The scale of the largest piece"
-cw3 60 50 10
-ct3 "left" "both" "left"
-field true
-minValue .1
-maxValue 100.0
-fieldMinValue .1
-fieldMaxValue 100.0
-value 2
scaleMaxSlider;
floatSliderGrp -label "Spread"
-ann "The radius-based distance from the locator from
which pieces will be created. Only works when a
locator is selected"
-cw3 60 50 10
-ct3 "left" "both" "left"
-field true
Chapter 5
148
-minValue 1
-maxValue 20
-fieldMinValue 1
-fieldMaxValue 20
-value 5
spreadSlider;
floatSliderGrp -label "Smoothness"
-ann "Defines the edges of the pebbles"
-cw3 60 50 10
-ct3 "left" "both" "left"
-field true
-minValue 0.10
-maxValue 1
-fieldMinValue .10
-fieldMaxValue 1
-value 0.75
coarseSlider;
frameLayout -l "Grouping" -collapsable 0 -borderStyle "etchedIn"
groupFrame;
columnLayout -adj 1 groupCol;
checkBox -label "Create Group"
-align "left"
-value 1
//-onc `textField -e -en 1 groupNameField`
-cc "groupOnOff()"
groupChkBox;
textField //-label "GroupName"
-en 1
-tx "DebrisGroup"
groupNameField;
button -l "Create Debris"
-c "debrisCmd ()"
createButton;
setParent mainCol;
//########### FRAME TWO: Needle specs ###########
Hands-On MEL Coding: km_debrisCreator
149
Chapter 5
frameLayout -l "Needle Specs " -collapsable 1 -borderStyle "etchedIn"
needlesFrame;
columnLayout -adj 1 needlesCol;
textFieldButtonGrp -label "Geo"
-text $path
-buttonLabel "Browse"
-bc "browseNeedle()"
-cw3 60 165 10
-ct3 "left" "both" "left"
browseTFG;
intSliderGrp -label "Amount"
-ann "The number of pieces"
-cw3 60 50 10
-ct3 "left" "both" "left"
-field true
-minValue 1
-maxValue 1000
-fieldMinValue 1
-fieldMaxValue 1000
-value 10
needlesAmountSlider;
// float $amountSlider = `floatSliderGrp -q -v needlesAmountSlider`;
floatSliderGrp -label "Spread"
-ann "The radius-based distance from the locator from
which pieces will be created. Only works when a
locator is selected"
-cw3 60 50 10
-ct3 "left" "both" "left"
-field true
-minValue 1
-maxValue 50
-fieldMinValue 1
-fieldMaxValue 50
-value 10
needlesSpreadSlider;
// float $spreadSlider = `floatSliderGrp -q -v needlesSpreadSlider`;
Chapter 5
150
floatSliderGrp -label "lengthOffset"
-ann "min = (original length - lengthOffset) and max
= (original length + lengthOffset)"
-cw3 60 50 10
-ct3 "left" "both" "left"
-field true
-minValue .1
-maxValue 50
-fieldMinValue .1
-fieldMaxValue 50
-value 5
needlesLengthSlider;
// float $lengthSlider = `floatSliderGrp -q -v needlesLengthSlider`;
floatSliderGrp -label "radiusOffset"
-cw3 60 50 10
-ct3 "left" "both" "left"
-field true
-minValue .001
-maxValue 5
-fieldMinValue .001
-fieldMaxValue 5
-value .3
needlesRadiusSlider;
// float $radiusSLider = `floatSliderGrp -q -v needlesRadiusSlider`;
floatSliderGrp -label "curveMin"
-ann "The min curvature of the needle"
-cw3 60 50 10
-ct3 "left" "both" "left"
-field true
-minValue .1
-maxValue 5
-fieldMinValue .1
-fieldMaxValue 5
-value .1
needlesCurvatureMinSlider;
Hands-On MEL Coding: km_debrisCreator
151
Chapter 5

Get Professional MEL Solutions for Production now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.