//Name: acMatchPoints.mel //Author: Allen Curtis //Date: January 2004 //Revised: May 27,2007 //Added buttons for inputting x, y, or z position of selected into textfield. //Description: Opens a window for aligning points on xyz axis so that they are tangent. //Good for working with nurbs, birails, etc. where endpoints must align or touch. //Moves the endpoint without moving the entire curve. //Select a point. Click the Point Position button to show the x, y, and z values in the top //label. Then select any other point or points that you wish to align to the first point. //Click the Align End Point button. Any points selected are moved to the position of the first point. //Basically the points are moved to whatever value is currently showing in the top xyz labels. //This script was an add-on to the movePoints script so those move functions are still available here. //The auto update was removed so that the alignment function would work correctly. //Select by Component Type: Points before opening acMatchPoints. //If selecting by object type or other component types you can still move the items, but //clicking on the Point Position button will result in an "object not found" error message. string $getCurrentSelected[]; float $positionNow[]; global proc acMatchPoints(){ if(`window -exists acMatchPointsWindow`) deleteUI acMatchPointsWindow; window -title "Match Points" -widthHeight 235 476 acMatchPointsWindow; columnLayout -columnOffset "left" 15 -rs 5 ColumnLayout; //Controls for viewing position of current selection. text -label "Selection" -m 1 SelectionLabel; text -label "x:" -align "left" labelX; text -label "y:" -align "left" labelY; text -label "z:" -align "left" labelZ; text -label "Point Position" -align "left" labelPointMessage; button -label "Point Position" -command "updateSelection" CurrentSelButton; button -label "Align End Points" -command "alignXYZ" AlignButton; text -label "_________________________________" -align "left";//hack for spacing checkBox -label "X axis" -value 1 checkX; checkBox -label "Y axis" checkY; checkBox -label "Z axis" checkZ; radioButtonGrp -numberOfRadioButtons 2 -columnAlign 1 "left" -columnWidth 1 60 -columnWidth 2 80 -label "Position:" -labelArray2 "Absolute" "Relative" -sl 2 radioCoordinates; //Layout inside another layout. formLayout -nd 100 xyzLayout; button -label "x" -width 20 -c "inputX" xButton; button -label "y" -width 20 -c "inputY" yButton; button -label "z" -width 20 -c "inputZ" zButton; text -label "- From Selected" fromSelected; columnLayout -parent ColumnLayout textLayout; //For user input. textField -width 80 PositionField; columnLayout -parent ColumnLayout buttonLayout; button -label "Move" -width 80 -command "moveXYZ" MoveXButton; //These floatFieldGrp's are invisible. Their only purpose here is //to use their precision flag as a round-off function for text labels. //-m/manage flag used for invisibility. floatFieldGrp -v1 0.0 -precision 6 -m 0 RoundOffX; floatFieldGrp -v1 0.0 -precision 6 -m 0 RoundOffY; floatFieldGrp -v1 0.0 -precision 6 -m 0 RoundOffZ; formLayout -edit -attachForm xButton "top" 5 -attachForm xButton "left" 5 -attachForm yButton "top" 5 -attachControl yButton "left" 10 xButton -attachForm zButton "top" 5 -attachControl zButton "left" 10 yButton -attachForm fromSelected "top" 5 -attachControl fromSelected "left" 5 zButton xyzLayout; window -edit -widthHeight 235 476 acMatchPointsWindow; showWindow acMatchPointsWindow; } //Aligns selected points to same xyz values as last Point Position setting. global proc alignXYZ(){ string $alignToPt[]; float $x; string $xvalue = `text -q -label labelX`; //Tokenize separates the string into an array. string $token = `tokenize $xvalue ":" $alignToPt`; //Could have made an extra float variable here, but string automatically casts (converts) to //a float value. $x = $alignToPt[1]; move -a -x $x; $xvalue = `text -q -label labelY`; $token = `tokenize $xvalue ":" $alignToPt`; $x = $alignToPt[1]; move -a -y $x; $xvalue = `text -q -label labelZ`; $token = `tokenize $xvalue ":" $alignToPt`; $x = $alignToPt[1]; move -a -z $x; } global proc inputX(){ string $inputSel[]; float $x; string $xvalue = `text -q -label labelX`; //Tokenize separates the string into an array. string $token = `tokenize $xvalue ":" $inputSel`; $x = $inputSel[1]; textField -edit -tx $x PositionField; } global proc inputY(){ string $inputSel[]; float $x; string $xvalue = `text -q -label labelY`; //Tokenize separates the string into an array. string $token = `tokenize $xvalue ":" $inputSel`; $x = $inputSel[1]; textField -edit -tx $x PositionField; } global proc inputZ(){ string $inputSel[]; float $x; string $xvalue = `text -q -label labelZ`; //Tokenize separates the string into an array. string $token = `tokenize $xvalue ":" $inputSel`; $x = $inputSel[1]; textField -edit -tx $x PositionField; } //Move position based on textfield's user input. global proc moveXYZ(){ string $getText = `textField -q -tx PositionField`; float $x = $getText; int $coordinates = `radioButtonGrp -q -sl radioCoordinates`; int $checkValX=`checkBox -query -value checkX`; if(($checkValX==1)&&($coordinates==1)){ move -a -x $x; }else if(($checkValX==1)&&($coordinates==2)){ move -r -x $x; } int $checkValY=`checkBox -query -value checkY`; if(($checkValY==1)&&($coordinates==1)){ move -a -y $x; }else if(($checkValY==1)&&($coordinates==2)){ move -r -y $x; } int $checkValZ=`checkBox -query -value checkZ`; if(($checkValZ==1)&&($coordinates==1)){ move -a -z $x; }else if(($checkValZ==1)&&($coordinates==2)){ move -r -z $x; }//end else } //Show current selection and position. If more than one vertex is selected, //only the first in the selection list is shown. global proc updateSelection(){ $getCurrentSelected =`ls -sl`; //Filter selected through selection masks (-sm). if(size(`filterExpand -sm 22 -sm 23 -sm 24 -sm 28 -sm 30 -sm 31 -sm 35 -sm 36 -sm 39 -sm 40 -sm 41 -sm 42 -sm 46 -sm 47 -sm 49 -sm 50 -sm 51 -sm 73`)>0){ //Create position variables; $positionNow = `pointPosition($getCurrentSelected[0])`; floatFieldGrp -edit -v1 $positionNow[0] RoundOffX; string $posXNow=`floatFieldGrp -q -v1 RoundOffX`; floatFieldGrp -edit -v1 $positionNow[1] RoundOffY; string $posYNow=`floatFieldGrp -q -v1 RoundOffY`; floatFieldGrp -edit -v1 $positionNow[2] RoundOffZ; string $posZNow=`floatFieldGrp -q -v1 RoundOffZ`; text -edit -label $getCurrentSelected[0] SelectionLabel; text -edit -label ("x: " + $posXNow) labelX; text -edit -label ("y: " + $posYNow) labelY; text -edit -label ("z: " + $posZNow) labelZ; //Can move some of these selection masks to next statement below //for object center to display if needed. }else if(size(`filterExpand -sm 0 -sm 1 -sm 2 -sm 3 -sm 4 -sm 5 -sm 6 -sm 7 -sm 8 -sm 9 -sm 10 -sm 11 -sm 13 -sm 14 -sm 15 -sm 16 -sm 17 -sm 18 -sm 19 -sm 20 -sm 21 -sm 25 -sm 26 -sm 27 -sm 29 -sm 32 -sm 33 -sm 34 -sm 37 -sm 38 -sm 43 -sm 44 -sm 45 -sm 48 -sm 52 -sm 53 -sm 54 -sm 55 -sm 56 -sm 57 -sm 67 -sm 69 -sm 70 -sm 71 -sm 72`)>0){ text -edit -label $getCurrentSelected[0] SelectionLabel; text -edit -label ("x:") labelX; text -edit -label ("y:") labelY; text -edit -label ("z:") labelZ; floatFieldGrp -edit -l "N/A" RoundOffX; }else if(size(`filterExpand -sm 12 -sm 68`)>0){ $positionNow = `objectCenter($getCurrentSelected[0])`; text -edit -label $getCurrentSelected[0] SelectionLabel; floatFieldGrp -edit -v1 $positionNow[0] RoundOffX; string $posXNow=`floatFieldGrp -q -v1 RoundOffX`; floatFieldGrp -edit -v1 $positionNow[1] RoundOffY; string $posYNow=`floatFieldGrp -q -v1 RoundOffY`; floatFieldGrp -edit -v1 $positionNow[2] RoundOffZ; string $posZNow=`floatFieldGrp -q -v1 RoundOffZ`; text -edit -label ("x:" + $posXNow) labelX; text -edit -label ("y:" + $posYNow) labelY; text -edit -label ("z:" + $posZNow) labelZ; } }