//James Parks //12-09-03 //jpAddVisControl.mel //Adds a channel to the chosen object that controls the //visibility of any number of other selected objects global proc AddVisControl() { string $winName = "AddVisControl"; if (`window -exists $winName`) deleteUI $winName; window -t "Add Vis Control" //-wh 100 35 -rtf 1 $winName ; rowColumnLayout -nr 4 -rh 1 25 -rh 2 25 -rh 3 25 -rh 4 25 ; textFieldButtonGrp -l "Control" -cw 1 80 -cw 2 100 -cal 1 "left" -cal 2 "left" -tx "...Select..." -bl "<--" -bc ("loadControl()") controlGrp; textFieldButtonGrp -l "Channel Name" -cw 1 80 -cw 2 100 -cal 1 "left" -cal 2 "left" -tx "...Channel Name..." -bl "?" -bc ("helpWindow()") visChannelGrp; radioButtonGrp -l "Default Value" -l1 "0" -l2 "1" -nrb 2 -cal 1 "left" -cal 2 "left" -cal 3 "left" -cw 1 80 -cw 2 50 -cw 3 50 -sl 1 defaultValueGrp; button -w 100 -l "Create" -c ("createVisChannel()"); // ; deleteUI -wnd " + $winName); showWindow $winName; } global proc loadControl() { string $selectedControl[] = `ls -sl`; textFieldButtonGrp -e -tx $selectedControl[0] controlGrp; } global proc createVisChannel() { string $controlObj = `textFieldButtonGrp -q -tx controlGrp`; string $channelName = `textFieldGrp -q -tx visChannelGrp`; int $defaultValue = `radioButtonGrp -q -sl defaultValueGrp`; if(!`attributeExists $channelName $controlObj`) { addAttr -at long -min 0 -max 1 -dv ($defaultValue -1) -ln $channelName $controlObj; setAttr -e -k 1 ($controlObj + "." + $channelName); } else print ("Attribute " + $channelName + " already exists. Selection added to vis control"); string $controlledObjects[] = `ls -sl`; for($obj in $controlledObjects) { connectAttr ($controlObj + "." + $channelName) ($obj + ".visibility"); } select $controlObj; } global proc helpWindow() { string $winName = "helpWindow"; if (`window -exists $winName`) deleteUI $winName; window -t "Add Vis Control -- Help Window" //-wh 100 35 -rtf 1 $winName ; rowColumnLayout -nr 6 -rh 1 15 -rh 2 15 -rh 3 15 -rh 4 15 -rh 5 15 -rh 6 15 ; text -l "1. Select the control object that you wish to add the channel to"; text -l "2. Press the '<--' button to load this object into the Control field"; text -l "3. Name the channel you wish to create"; text -l "4. Select the objects you want controlled by your new channel"; text -l "5. Choose a default value for your vis channel"; text -l "6. Press the 'Create' button"; showWindow $winName; } AddVisControl;