/* ScriptName: acSelectByPosition Author: Allen Curtis Date: May 27, 2007 Purpose of script: To find all vertices within selected objects that have xyz position within a maximum and minimum range. Adjust the range using the minimum and maximum sliders. This script can help eliminate problems with mirrored geometry resulting from midpoint vertices not all being at exactly 0. ---------------------------------------------------------------------- Instructions: Select one or more objects in component mode. Adjust minimum and maximum range of sliders. Select an axis by checking one of the Axis checkboxes. You can check more than one axis. Click the Select In Range button. Any vertices within the slider range along the axis are selected. ---------------------------------------------------------------------- Details: The Sliders Min/Max/Step textfields adjust the allowable range of the sliders. Enable the Min radio button to edit the Minimum Position slider. Enable the Max radio button to edit the Maximum Position slider. ---------------------------------------------------------------------- Use and modify this script at own risk. */ global proc acSelectByPosition(){ if(`window -exists acBPWindow`) deleteUI acBPWindow; window -widthHeight 420 140 -title "Select By Position" -rtf true acBPWindow; string $form = `formLayout -numberOfDivisions 100`; columnLayout -adjustableColumn false SliderLayout; floatSliderGrp -label "Minimum Position" -field true -minValue -10.0 -maxValue 10.0 -fieldMinValue -100.0 -fieldMaxValue 100.0 -step .01 -value 0 MinSliderGrp; floatSliderGrp -label "Maximum Position" -field true -minValue -10.0 -maxValue 10.0 -fieldMinValue -100.0 -fieldMaxValue 100.0 -step .01 -value 0 MaxSliderGrp; columnLayout -adjustableColumn false -p $form checkBoxLayout; checkBoxGrp -numberOfCheckBoxes 3 -label "Axis" -labelArray3 "X" "Y" "Z" -value1 1 axisCheckBox; columnLayout -adjustableColumn false -p $form rangeLayout; string $rangeButton = `button`; button -edit -label "Select in Range" -command "getVerticesWithinRange" $rangeButton; columnLayout -adjustableColumn false -p $form closeButtonLayout; string $closeButton = `button`; button -edit -label "Close" -width 60 -c "deleteUI acBPWindow" $closeButton; columnLayout -adjustableColumn false -p $form radioLayout; radioButtonGrp -numberOfRadioButtons 2 -columnAlign 1 "left" -columnWidth 1 100 -columnWidth 2 80 -label "Min/Max Edit" -labelArray2 "Min" "Max" -sl 2 radioMinMax; columnLayout -adjustableColumn false -p $form ffGrpLayout; floatFieldGrp -nf 3 -l "Sliders Min/Max/Step" -v1 -10 -v2 10 -v3 0.01 -pre 4 editBPSlidersField; columnLayout -adjustableColumn false -p $form bpSliderButtonLayout; button -label "Edit Sliders" -command "editBPSliders" bpSliderButton; formLayout -edit -attachForm SliderLayout "top" 5 -attachForm SliderLayout "left" 5 -attachControl SliderLayout "bottom" 5 checkBoxLayout -attachNone checkBoxLayout "top" -attachForm checkBoxLayout "left" 5 -attachControl checkBoxLayout "bottom" 10 rangeLayout -attachNone rangeLayout "top" -attachForm rangeLayout "left" 165 -attachControl rangeLayout "bottom" 10 radioLayout -attachNone closeButtonLayout "top" -attachControl closeButtonLayout "left" 40 rangeLayout -attachControl closeButtonLayout "bottom" 10 radioLayout -attachNone radioLayout "top" -attachForm radioLayout "left" 100 -attachControl radioLayout "bottom" 10 ffGrpLayout -attachNone ffGrpLayout "top" -attachForm ffGrpLayout "left" 15 -attachForm ffGrpLayout "bottom" 30 -attachNone bpSliderButtonLayout "top" -attachForm bpSliderButtonLayout "right" 40 -attachForm bpSliderButtonLayout "bottom" 31 $form; window -edit -widthHeight 520 230 acBPWindow; showWindow acBPWindow; } global proc getVerticesWithinRange(){ //Lists objects hilited for component selection. string $obj[] = `ls -hilite`; //Minimum and maximum range of position. float $Min = `floatSliderGrp -q -value MinSliderGrp`; float $Max = `floatSliderGrp -q -value MaxSliderGrp`; int $checkXAxis=`checkBoxGrp -query -value1 axisCheckBox`; int $checkYAxis=`checkBoxGrp -query -value2 axisCheckBox`; int $checkZAxis=`checkBoxGrp -query -value3 axisCheckBox`; for($eachObject in $obj){ //Get vertex amount of each object. int $vertCounts[] = ` polyEvaluate -vertex $eachObject `; int $i; float $pos[3]; for ($i=0; $i<$vertCounts[0]; $i++) { string $vertex = $eachObject + ".vtx[" + $i +"]"; $pos = `xform -q -ws -t $vertex`;//Get position. if(($pos[0] >= $Min) && ($pos[0] <= $Max) && ($checkXAxis==1)) { select -add $vertex;//Needs the -add flag here to work. }else if(($pos[1] >= $Min) && ($pos[1] <= $Max) && ($checkYAxis==1)) { select -add $vertex; }else if(($pos[2] >= $Min) && ($pos[2] <= $Max) && ($checkZAxis==1)) { select -add $vertex; }//if else ends }//inner for ends }//outer for ends $obj = `ls -sl -fl`;//Need the -flatten flag to get correct count here. string $print = size($obj) + " vertices selected by position." + "\n"; print($print); $obj = `ls -hl`; $print = "Objects hilited: " + size($obj) + "\n"; print($print); } global proc editBPSliders(){ float $editBPMin = `floatFieldGrp -q -v1 editBPSlidersField`; float $editBPMax = `floatFieldGrp -q -v2 editBPSlidersField`; float $editStep = `floatFieldGrp -q -v3 editBPSlidersField`; int $radioSetting = `radioButtonGrp -q -sl radioMinMax`; //If Min radio button is enabled, edit the Minimum slider. //If Max radio button is enabled, edit the Maximum slider. if($radioSetting==1){ floatSliderGrp -edit -minValue $editBPMin -maxValue $editBPMax -fieldMinValue $editBPMin -fieldMaxValue $editBPMax -step $editStep MinSliderGrp; }else if($radioSetting==2){ floatSliderGrp -edit -minValue $editBPMin -maxValue $editBPMax -fieldMinValue $editBPMin -fieldMaxValue $editBPMax -step $editStep MaxSliderGrp; } }