// fPolyTools; // Tagincev Vladislav global proc fPolyTools() { if (`menu -exists fPolyTools`) deleteUI fPolyTools; else { menu -l "fPolyTools" -tearOff true -p "MayaWindow" fPolyTools; menuItem -l "Comnine" -c "fComnine();" -ann "Smart Combine" ; menuItem -l "Duplicate Face" -c "fDuplicateFace();" -ann "Duplicate Face"; menuItem -l "Extract Face" -c "fExtractFace();" -ann "Extract Face"; menuItem -divider true; menuItem -l "Extrude" -c "fExtrude;" -ann "Extrude"; menuItem -l "Collapse" -c "fMinMaxProc(1);fMinMaxProc(2);fMinMaxProc(3);polyMergeVertex -d 1;" -ann "Collapse to center"; menuItem -divider true; menuItem -subMenu true -tearOff true -label "Select"; menuItem -l "Shell" -c "fSelectShell();" -ann "Select Shell or UV Shell"; menuItem -l "Shell Border" -c "fSelectShellBorder();" -ann "Select Shell Border"; menuItem -l "Shape Border" -c "fSelectObjBorder();" -ann "Select Shape Border"; menuItem -l "Face Border" -c "fFaceBorder();" -ann "Select Selected Faces Border"; menuItem -l "Hard Edge" -c "fHardEdgeSel();" -ann "Select Hard Edges"; menuItem -l "Edge Short Path" -c "fShortPath();" -ann "Select Edge Short Path"; menuItem -divider true; menuItem -subMenu true -tearOff true -label "Material"; menuItem -l "Face Materials" -c "fMatFace();" -ann "Select Face Materials"; menuItem -l "Unused Materials" -c "fMatUnused();" -ann "Select Unused Materials"; setParent -menu ..; menuItem -divider true; menuItem -l "Next Loop Edge" -c "fNextLoopEdgeSelect;" -ann "Next Loop Edge Select"; menuItem -l "Next Ring Edge" -c "fNextRingEdgeSelect;" -ann "Next Ring Edge Select"; menuItem -l "Next Edge UI" -c "fNextEdgeSelectUI;" -ann "Next Steps Edge Select"; menuItem -divider true; menuItem -l "Edge Loop Part" -c "fEdgeLoopPartSel;" -ann "Select Edge Loop Part (for two edges)"; menuItem -l "Vertex Loop" -c "fVertexLoop;" -ann "Select Vertex Loop"; menuItem -divider true; menuItem -l "Symmetry Part" -c "fSelectTools;" -ann "Select Tools"; menuItem -l "Edge Loop Faces" -c "fSelectEdgeLoopPart();" -ann "Select Edge Loop Faces Part"; menuItem -l "Invert Shell" -c "fInvertSelShell();" -ann "Invert for Shell Select"; setParent -menu ..; menuItem -subMenu true -tearOff true -label "Fit Tools"; menuItem -subMenu true -tearOff true -label "to Max"; menuItem -l "X" -c "fMinMaxMove (0,0);" -ann "Fit to X Max"; menuItem -l "Y" -c "fMinMaxMove (1,0);" -ann "Fit to Y Max"; menuItem -l "Z" -c "fMinMaxMove (2,0);;" -ann "Fit to Z Max"; setParent -menu ..; menuItem -subMenu true -tearOff true -label "to Center"; menuItem -l "X" -c "fMinMaxProc(1);" -ann "Fit to X"; menuItem -l "Y" -c "fMinMaxProc(2);" -ann "Fit to Y"; menuItem -l "Z" -c "fMinMaxProc(3);" -ann "Fit to Z"; menuItem -l "XYZ" -c "fMinMaxProc(1);fMinMaxProc(2);fMinMaxProc(3);" -ann "Fit to Z"; setParent -menu ..; menuItem -subMenu true -tearOff true -label "to Min"; menuItem -l "X" -c "fMinMaxMove (0,1);" -ann "Fit to X Min"; menuItem -l "Y" -c "fMinMaxMove (1,1);" -ann "Fit to Y Min"; menuItem -l "Z" -c "fMinMaxMove (2,1);;" -ann "Fit to Z Min"; setParent -menu ..; menuItem -subMenu true -tearOff true -label "to Grid"; menuItem -l "X" -c "move -x 0;" -ann "Move to X"; menuItem -l "Y" -c "move -y 0;" -ann "Move to Y"; menuItem -l "Z" -c "move -z 0;" -ann "Move to Z"; menuItem -l "XYZ" -c "move 0 0 0;" -ann "Move to Z"; setParent -menu ..; menuItem -divider true; menuItem -subMenu true -tearOff true -label "Mirror Face"; menuItem -l "X" -c "fMirFace(-1,1,1);" -ann "Mirror Face X"; menuItem -l "Y" -c "fMirFace(1,-1,1);" -ann "Mirror Face Y"; menuItem -l "Z" -c "fMirFace(1,1,-1);" -ann "Mirror Face Z"; setParent -menu ..; menuItem -subMenu true -tearOff true -label "Mirror Shape"; menuItem -l "X" -c "fMirShape(-1,1,1);" -ann "Mirror Shape X"; menuItem -l "Y" -c "fMirShape(1,-1,1);" -ann "Mirror Shape Y"; menuItem -l "Z" -c "fMirShape(1,1,-1);" -ann "Mirror Shape Z"; setParent -menu ..; menuItem -divider true; menuItem -l "to Shape" -c "fSTSMove;" -ann "STSMove"; menuItem -l "to Edge Line" -c "fFitToEdgeLine;" -ann "Fit To Edge Line"; menuItem -divider true; menuItem -l "World Space Obj" -c "fLWfit;" -ann "Fit to World Space for Obj"; menuItem -l "World Space Vertex" -c "fLWfitVertex;" -ann "Fit to World Space for Vertex"; menuItem -l "Kill Freeze " -c "fKillFreeze;" -ann "Delete Freeze Transformations. From Local Spase to World."; setParent -menu ..; menuItem -subMenu true -tearOff true -label "Memory"; menuItem -l "Memory Selected" -c "fMemory(0);" -ann "Memory Selected"; menuItem -divider true; menuItem -l "Add to Memory Select" -c "fMemory(1);" -ann "Add to Memory Select"; menuItem -l "Del from Memory Select" -c "fMemory(4);" -ann "Delete from Memory Select"; menuItem -divider true; menuItem -l "Select From Memory" -c "fMemory(2);" -ann "Select From Memory"; menuItem -divider true; menuItem -l "Clear Memory" -c "fMemory(3);" -ann "Clear Memory"; menuItem -l "List Memory" -c "fMemory(5);" -ann "Print All"; setParent -menu ..; menuItem -subMenu true -tearOff true -label "Misk"; menuItem -l "Curve From Normal" -c "fCurveFromNormal;" -ann "Curve From Normal"; menuItem -subMenu true -label "Smooth Edge Ring"; menuItem -l "Exponential" -c "fSmoothEdgeRing(0);" -ann "Exponential Smooth Edge Ring"; menuItem -l "Linear" -c "fSmoothEdgeRing(1);" -ann "Linear Smooth Edge Ring"; setParent -menu ..; menuItem -subMenu true -label "Cut XYZ"; menuItem -l "Cut YZ" -c "fCutZero(0,90,0);" -ann "Clear Memory"; menuItem -l "Cut XZ" -c "fCutZero(90,0,0);" -ann "Clear Memory"; menuItem -l "Cut XY" -c "fCutZero(0,0,0);" -ann "Clear Memory"; menuItem -l "Cut XYZ" -c "fCutZero(0,90,0);fCutZero(90,0,0);fCutZero(0,0,0);" -ann "Clear Memory"; setParent -menu ..; menuItem -l "Invert Topology" -c "fInvertTopology;" -ann "Invert Topology"; menuItem -l "Pixel Move" -c "fPixelMove;" -ann "Pixel Move"; menuItem -l "VAverage" -c "FNDVAverage;" -ann "Average Vertex (for average and move back vertex)"; setParent -menu ..; menuItem -subMenu true -tearOff true -label "Render"; menuItem -subMenu true -label "Create Shading Network"; menuItem -l "misss_fast_shader" -c "fMentalSSS(\"misss_fast_shader\");" -ann "Create Shading Network for misss_fast_shader"; menuItem -l "misss_fast_simple_maya" -c "fMentalSSS(\"misss_fast_simple_maya\");" -ann "Create Shading Network for misss_fast_simple_maya"; menuItem -l "misss_fast_skin_maya" -c "fMentalSSS(\"misss_fast_skin_maya\");" -ann "Create Shading Network for misss_fast_skin_maya"; setParent -menu ..; menuItem -l "Distance From Camera" -c "fDisFromCamUI;" -ann "Distance From Camera (for VERTEX)"; menuItem -l "Bounding Box Size" -c "fBBSizeUI;" -ann "Bounding Box Size For All Poly Shapes"; setParent -menu ..; menuItem -subMenu true -tearOff true -label "Utils"; menuItem -l "Show Free Memory" -cb `headsUpDisplay -ex fShowMemory` -c "fShowFreeMemory;" -ann "Show Free Memory (headsUpDisplay)"; menuItem -l "Show Frame" -cb `headsUpDisplay -ex fShowFrame` -c "fShowFrame;" -ann "Show Frame (headsUpDisplay)"; menuItem -divider true; menuItem -l "Clear Undo" -c "fClearUndo;" -ann "Clear Undo"; menuItem -l "Make Clone" -c "fMakeClone;" -ann "Make Clone"; menuItem -l "Poly Count" -c "fPCountUI;" -ann "Poly Count"; menuItem -l "Foreach" -c "fForeach;" -ann "Foreach"; menuItem -l "Replace Instance" -c "fKillInstance;" -ann "Replace Instance"; menuItem -l "Calculator" -c "fCalculator();" -ann "Calculator"; setParent -menu ..; setParent -menu ..; } } global proc fDuplicateFace() { $fStartTime = `timerX`; ConvertSelectionToFaces; string $rootSelectFaces[] = `ls -sl`; SelectToggleMode; string $RootObj[] = `ls -sl`; duplicate; string $NextObj[] = `ls -sl`; string $FaceNameString = stringArrayToString($rootSelectFaces , " "); string $bufferP[]; tokenize $FaceNameString ". " $bufferP; string $bufferP[] = stringArrayRemove($RootObj, $bufferP); string $NextFaceNameString = stringArrayToString($bufferP , " "); string $NextFaceNameString = substituteAllString($NextFaceNameString, "f",($NextObj[0]+".f")); tokenize $NextFaceNameString " " $bufferP; select $bufferP; InvertSelection; doDelete; select $NextObj; $fTotalTime = `timerX -startTime $fStartTime`; print ("Total Duplicate Time: "+$fTotalTime+"\n"); } global proc fExtractFace() { $fStartTime = `timerX`; ConvertSelectionToFaces; string $rootSelectFaces[] = `ls -sl`; SelectToggleMode; string $RootObj[] = `ls -sl`; duplicate; string $NextObj[] = `ls -sl`; string $FaceNameString = stringArrayToString($rootSelectFaces , " "); string $bufferP[]; tokenize $FaceNameString ". " $bufferP; string $bufferP[] = stringArrayRemove($RootObj, $bufferP); string $NextFaceNameString = stringArrayToString($bufferP , " "); string $NextFaceNameString = substituteAllString($NextFaceNameString, "f",($NextObj[0]+".f")); tokenize $NextFaceNameString " " $bufferP; select $bufferP; InvertSelection; doDelete; select $rootSelectFaces; doDelete; select $NextObj; $fTotalTime = `timerX -startTime $fStartTime`; print ("Total Extract Time: "+$fTotalTime+"\n"); } global proc fComnine() { print "fComnine;\n"; DeleteHistory; string $selectStart[] = `ls -sl -fl`; select $selectStart[0]; vector $stPiv = `xform -ws -q -t`; select $selectStart; polyUnite -ch 0; rename $selectStart[0]; move ($stPiv.x) ($stPiv.y) ($stPiv.z); ConvertSelectionToVertices; vector $stPivN = (<<0,0,0>> - $stPiv); move -r ($stPivN.x) ($stPivN.y) ($stPivN.z); select -cl; } global proc fSelectShell() { SelectUVShell; } global proc fSelectShellBorder() { SelectUVBorder; } global proc fInvertSelShell() { string $fStart[] = `ls -sl`; fSelectShell; select -d $fStart; } global proc fSelectObjBorder() { //print "fSelectObjBorder;\n"; string $fStartSelect[] = `ls -sl -fl -o`; select $fStartSelect; ConvertSelectionToEdges; SelectUVBorder; hilite -r $fStartSelect; } global proc fHardEdgeSel() { print "fHardEdgeSel;\n"; fSelectObjBorder; string $fDeSelect[] = `ls -sl -fl`; string $fStartSelect[] = `ls -sl -fl -o`; select $fStartSelect; ConvertSelectionToEdges; string $fSelectEdge[] = `ls -sl -fl`; string $fForEdge; select -cl; for ($fForEdge in $fSelectEdge) { string $HardTest[] = `polyInfo -ev $fForEdge`; if (endString (`strip $HardTest[0]`,4) == "Hard") { select -add $fForEdge; } } select -d $fDeSelect; hilite -r $fStartSelect; } global proc fMemory(int $checkadd) { global string $fGlobalMemoryselect[]; if ($checkadd == 0) { global string $fGlobalMemoryselect[]; string $fGlobalMemoryselect[] = `ls -sl -fl`; } if ($checkadd == 1) { global string $fGlobalMemoryselect[]; string $fGlobalMemoryselectNew[] = `ls -sl -fl`; $fGlobalMemoryselect = stringArrayCatenate( $fGlobalMemoryselect, $fGlobalMemoryselectNew); $fGlobalMemoryselect = stringArrayRemoveDuplicates($fGlobalMemoryselect); } if ($checkadd == 2) { global string $fGlobalMemoryselect[]; select $fGlobalMemoryselect; } if ($checkadd == 3) { global string $fGlobalMemoryselect[]; string $fGlobalMemoryselect[] = {}; } if ($checkadd == 4) { global string $fGlobalMemoryselect[]; string $fGlobalMemoryselectNew[] = `ls -sl -fl`; string $fGlobalMemoryselect[] = stringArrayRemoveExact ($fGlobalMemoryselectNew,$fGlobalMemoryselect); } if ($checkadd == 5) { global string $fGlobalMemoryselect[]; print "---------------\n"; print $fGlobalMemoryselect; if (`size $fGlobalMemoryselect` == 0) print "Memory clear\n"; print "---------------\n"; } } global proc fNextLoopEdgeSelect() { //print "fNextLoopEdgeSelect;\n"; string $fStartEdge[] = `ls -sl -fl`; PolySelectTraverse 1; string $fNExtEdge[] = `ls -sl -fl`; select $fStartEdge; SelectEdgeLoop; string $fLoopEdge[] = `ls -sl -fl`; fSelectObjBorder; select -add $fLoopEdge; string $fLoopEdge[] = `ls -sl -fl`; string $fLast[] = stringArrayRemoveExact($fNExtEdge, $fLoopEdge); string $fLast[] = stringArrayRemoveExact ($fLast,$fLoopEdge); select $fLast; } global proc fNextRingEdgeSelect() { //print "fNextRingEdgeSelect;\n"; string $fStartEdge[] = `ls -sl -fl`; ConvertSelectionToFaces; ConvertSelectionToEdges; string $fNExtEdge[] = `ls -sl -fl`; select $fStartEdge; SelectEdgeRing; string $fLoopEdge[] = `ls -sl -fl`; string $fLast[] = stringArrayRemoveExact($fNExtEdge, $fLoopEdge); string $fLast[] = stringArrayRemoveExact ($fLast,$fLoopEdge); select $fLast; } /////////////Fit Tools///////////// global proc fMinMaxProc(int $fCheck) { ConvertSelectionToVertices; if ($fCheck==3) { int $fi=2; float $fAllFloat[] = `xform -ws -q -t`; int $fSize = `size $fAllFloat`; global float $fNeadFArray[]; float $fNeadFArray[] = {}; int $i; for ($i = 0; $i < $fSize; $i++) { if ($i==$fi) { global float $fNeadFArray[]; $fNeadFArray[`size $fNeadFArray`]=$fAllFloat[$i]; $fi = $fi + 3; } } float $fMaxim = fFindCenterValue(); move -z $fMaxim; } if ($fCheck==2) { int $fi=1; float $fAllFloat[] = `xform -ws -q -t`; int $fSize = `size $fAllFloat`; global float $fNeadFArray[]; float $fNeadFArray[] = {}; int $i; for ($i = 0; $i < $fSize; $i++) { if ($i==$fi) { global float $fNeadFArray[]; $fNeadFArray[`size $fNeadFArray`]=$fAllFloat[$i]; $fi = $fi + 3; } } float $fMaxim = fFindCenterValue(); move -y $fMaxim; } if ($fCheck==1) { int $fi=0; float $fAllFloat[] = `xform -ws -q -t`; int $fSize = `size $fAllFloat`; global float $fNeadFArray[]; float $fNeadFArray[] = {}; int $i; for ($i = 0; $i < $fSize; $i++) { if ($i==$fi) { global float $fNeadFArray[]; $fNeadFArray[`size $fNeadFArray`]=$fAllFloat[$i]; $fi = $fi + 3; } } float $fMaxim = fFindCenterValue(); move -x $fMaxim; } } global proc float fFindCenterValue() { global float $fNeadFArray[]; int $fin = `size $fNeadFArray`; float $fCenter = 0; for ($i = 0; $i <= ($fin-1); $i++) { float $fCenter = ($fCenter + $fNeadFArray[$i]); if ($i==($fin-1)) {$fCenter = ($fCenter/$fin); return$fCenter;} } } ///////////////////////////////////////////////// global proc fCutZero(float $FNDX, float $FNDY,float $FNDZ) { string $FNDSelect[] = `ls -sl -fl`; if (`size $FNDSelect` > 1) { DeleteHistory; polyUnite -ch 0; polyCut -ws 1 -rx $FNDX -ry $FNDY -rz $FNDZ -ch 0; rename $FNDSelect[0]; } else { polyCut -ws 1 -rx $FNDX -ry $FNDY -rz $FNDZ -ch 1; } } ///////////////////////////////////////////// global proc fExtrude() { int $sel; $sel = fSelFilter(); if ($sel==1) ExtrudeVertex; else if ($sel==2) ExtrudeEdge; else if ($sel==3) ExtrudeFace; else if ($sel==0) ExtrudeFace; } //////////////////// Select Zero global proc fSelectTools() { print "fSelectTools;\n"; if (`window -exists fSelectTools`) {deleteUI fSelectTools;} string $window = `window -title "SelectTools" -s 0 -iconName "STools" fSelectTools`; rowColumnLayout -numberOfColumns 3 ; button -l "+ X" -c "fSelectZero(1,1,$FNDTolerance,$FNDConvertToFace)"; button -l "+ Y" -c "fSelectZero(2,1,$FNDTolerance,$FNDConvertToFace)"; button -l "+ Z" -c "fSelectZero(3,1,$FNDTolerance,$FNDConvertToFace)"; button -l "- X" -c "fSelectZero(1,2,$FNDTolerance,$FNDConvertToFace)"; button -l "- Y" -c "fSelectZero(2,2,$FNDTolerance,$FNDConvertToFace)"; button -l "- Z" -c "fSelectZero(3,2,$FNDTolerance,$FNDConvertToFace)"; text -label "Tolerance:" -align "center"; global string $FNDTolerance; string $FNDTolerance = `floatField -v 0.001`; global string $FNDConvertToFace; string $FNDConvertToFace = `checkBox -v 1 -l "Faces" -align "left" `; setParent ..; showWindow $window; } global proc fSelectZero(int $XYZ, int $PlusOrMin, string $ToleranceR, string $ConvertToFaceR) { float $ToleranceRead = `floatField -q -value $ToleranceR`; int $ToFace = `checkBox -q -v $ConvertToFaceR`; ConvertSelectionToVertices; string $AllVetr[] = `ls -sl -fl`; int $fAllVertSize = `size $AllVetr`; string $SVert; select -cl; progressWindow -title ("Vertex Count: "+$fAllVertSize) -progress 0 -max $fAllVertSize -status "Start" -isInterruptable true; int $Comp = 1; for ($SVert in $AllVetr) { if ( `progressWindow -query -isCancelled` ) break; vector $vetXform = `xform -r -q -t $SVert`; global float $FNDtestTrue; switch ($XYZ) { case 1: global float $FNDtestTrue; float $FNDtestTrue = ($vetXform.x); break; case 2: global float $FNDtestTrue; float $FNDtestTrue = ($vetXform.y); break; case 3: global float $FNDtestTrue; float $FNDtestTrue = ($vetXform.z); break; } switch ($PlusOrMin) { case 1: global float $FNDtestTrue; if ($FNDtestTrue >= $ToleranceRead) {select -add $SVert;} break; case 2: global float $FNDtestTrue; if ($FNDtestTrue <= -$ToleranceRead) {select -add $SVert;} break; } progressWindow -edit -progress $Comp -status ("Computed: "+$Comp); $Comp = $Comp + 1; } progressWindow -endProgress; if ($ToFace==1) ConvertSelectionToFaces; deleteUI fSelectTools; } ////////////////////// STS global proc fSTSMoveDo(string $fSTSLength,string $fTarget) { float $Height = `floatField -q -value $fSTSLength`; string $nameTarget = `textField -q -text $fTarget`; global string $fSTSundo; int $fConfirm = `checkBox -q -v $fSTSundo`; if ($fConfirm==1) undoInfo -state off; ConvertSelectionToVertices; string $nameAllVert[] = `ls -sl -fl`; { string $ftest[] = `ls -fl $nameTarget`; if (`size $ftest`==0) error "No target"; } int $checkSize = `size $nameAllVert`; if ($checkSize != 0){ progressWindow -title ("Count: "+$checkSize) -progress 0 -max $checkSize -status "Start" -isInterruptable true; int $Comp = 1; string $forVert; SelectToggleMode; string $nameMainObj[] = `ls -sl`; for ($forVert in $nameAllVert) { float $fMemoryFr[] = `memory -fr`; if ( `progressWindow -query -isCancelled` ) break; select $forVert; float $vertXform[] = `xform -q -ws -t`; string $nameGeom = $nameTarget; spaceLocator -n "Helper"; move -ws $vertXform[0] $vertXform[1] $vertXform[2]; select $nameGeom "Helper"; geometryConstraint -weight 1; normalConstraint -weight 1 -aimVector 0 1 0 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0; select "Helper"; select `ls -sl -dag`; select -d "Helper" `ls -sl -s`; doDelete; select "Helper"; float $normalMove = $Height; move -r -os -wd -y $normalMove ; float $vertXform[] = `xform -q -ws -t`; doDelete; select $forVert; move -ws $vertXform[0] $vertXform[1] $vertXform[2]; progressWindow -edit -progress $Comp -title ("Free Memory: "+$fMemoryFr[0]) -status ("Computed: "+$Comp+" (Count: "+$checkSize+")"); $Comp = $Comp + 1; } progressWindow -endProgress; SelectVertexMask; select $nameAllVert; hilite $nameMainObj[0]; } if ($fConfirm==1) undoInfo -state on; } global proc fSTSMove() { print "fSTSMove;\n"; if (`window -exists fShapeToShapeMove`) {deleteUI fShapeToShapeMove;} string $window = `window -title "Shape To Shape Move" -iconName "STSMove" fShapeToShapeMove`; columnLayout -adjustableColumn true; global string $fSTSundo; string $fSTSundo = `checkBox -label "No Undo" -align "left" -v 0`; setParent ..; rowColumnLayout -numberOfColumns 2; text -label "Height:"; global string $fSTSLength; string $fSTSLength = `floatField -v 0`; text -label "Name target obj:"; global string $fTarget; string $fTarget = `textField`; separator -height 3 -style "none"; separator -height 3 -style "none"; button -label "STSMove" -c ("fSTSMoveDo($fSTSLength,$fTarget)"); button -label "Pick Name" -c ("fSTSpickName($fTarget)"); setParent ..; showWindow $window; } global proc fSTSpickName(string $Target) { string $newNameObjs[] = `ls -sl -fl`; if (`size $newNameObjs` == 1) { string $newName = $newNameObjs[0]; textField -e -text $newName $Target; } else error "???"; } ///////////////// SmoothEdge global proc fSmoothEdgeRing(int $fksb) { print "fSmoothEdgeRing;\n"; polySelectEdges edgeRing; string $fstartRingEdge[] = `ls -sl -fl`; getFaces; global string $fslFaces[]; global string $fdiffF = ""; $fslFaces = `ls -sl -fl`; string $fforFace; for ($fforFace in $fslFaces) { select $fforFace; ConvertSelectionToVertices; string $ftest[]= `ls -sl -fl`; int $fSizeV = `size $ftest`; if ($fSizeV != 4) $fdiffF = ($fdiffF+$fforFace+" "); } string $fdiffFaceArray[] = stringToStringArray($fdiffF, " "); string $fdiffRingEdgeRez[] = stringArrayRemove($fdiffFaceArray,$fslFaces); select $fdiffRingEdgeRez; if ($fksb == 1){ polySmooth -mth 1 -dv 1 -c 1 -kb 0 -ksb 0 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 1 -ro 1 -ch 1 ;} if ($fksb == 0){ polySmooth -mth 0 -dv 1 -c 1 -kb 0 -ksb $fksb -khe 0 -kt 1 -kmb 1 -suv 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 ;} string $flastHelpRingEdgeFace[] = `ls -sl -fl`; GrowPolygonSelectionRegion; select -d $flastHelpRingEdgeFace; ConvertSelectionToEdges; string $flastHelpRingEdge[] = `ls -sl -fl`; select $flastHelpRingEdgeFace; ConvertSelectionToEdges; string $fallRingEdge[] = `ls -sl -fl`; select $fstartRingEdge; fNextLoopEdgeSelect; GrowPolygonSelectionRegion; string $flastRingEdge[] = `ls -sl -fl`; string $flastRingEdge[] = stringArrayCatenate( $flastRingEdge, $flastHelpRingEdge); string $fdiffRingEdge[] = stringArrayRemove($flastRingEdge,$fallRingEdge); select $fdiffRingEdge; DeleteEdge -ch 1; $fstartRingEdge = {""}; $fslFaces = {""}; $flastRingEdge = {""}; $fdiffRingEdgeRez = {""}; $fdiffF = ""; $flastHelpRingEdge = {""}; } ////////////////////////////// Curve normal global proc fCurveFromNormal() { print "fCurveFromNormal;\n"; if (`window -exists fCurveFromNormal`) deleteUI fCurveFromNormal; string $fcfnwindow = `window -title "Curve From Normal" -iconName "CFN" fCurveFromNormal`; columnLayout -adjustableColumn true; setParent ..; rowColumnLayout -numberOfColumns 2; global string $fcfnLengthL; $fcfnLengthL= `text -label "Length:"` ; global string $fcfnLength; string $fcfnLength = `floatField -v 1`; global string $fcfnNSpansL; $fcfnNSpansL = `text -label "Number of spans:"`; global string $fcfnNSpans; string $fcfnNSpans = `intField -v 4`; text -label "Name emited curve:"; global string $fcfnname; string $fcfnname = `textField -text "n_curve" -en 0`; setParent ..; columnLayout -adjustableColumn true -rowSpacing 0; global string $fcfnCheckName; string $fcfnCheckName = `checkBox -v 0 -l "Use name from scene" -align "center" -onc "text -e -en 0 $fcfnLengthL; text -e -en 0 $fcfnNSpansL; intField -e -en 0 $fcfnNSpans; floatField -e -en 0 $fcfnLength; textField -e -text \"\" $fcfnname;" -ofc "text -e -en 1 $fcfnLengthL; text -e -en 1 $fcfnNSpansL; intField -e -en 1 $fcfnNSpans; floatField -e -en 1 $fcfnLength; textField -e -text \"n_curve\" $fcfnname;" `; global string $fcfnCheckNormal; string $fcfnCheckNormal = `checkBox -v 1 -l "Use normal" -align "center" `; global string $fcfnCheckInstance; string $fcfnCheckInstance = `checkBox -v 0 -l "Instance" -align "center" `; setParent ..; rowColumnLayout -numberOfColumns 2; button -label "Pick Name" -c ("pickName($fcfnname,$fcfnCheckName)"); popupMenu; global string $fUnlockC; $fUnlockC = `menuItem -l "Unlock name" -en 1 -c "textField -e -en 1 $fcfnname; menuItem -e -en 1 $fLockC; menuItem -e -en 0 $fUnlockC;"`; global string $fLockC; $fLockC = `menuItem -l "Lock name" -en 0 -c "textField -e -en 0 $fcfnname; menuItem -e -en 0 $fLockC; menuItem -e -en 1 $fUnlockC;"`; button -label "Create Curve" -c ("fCreateCurve($fcfnLength,$fcfnNSpans,$fcfnname)"); setParent ..; columnLayout -adjustableColumn true -rowSpacing 0; button -label "Create" -c ("fCheckProc($fcfnLength,$fcfnNSpans,$fcfnname,$fcfnCheckName,$fcfnCheckNormal)"); setParent ..; showWindow $fcfnwindow; } global proc fCheckProc(string $fcfnLength, string $fcfnNSpans, string $fcfnname, string $fcfnCheckName, string $fcfnCheckNormal) { global string $fcfnnameCobj; string $fcfnnameCobj = `textField -q -text $fcfnname`; global int $fcfnCheckRead; int $fcfnCheckRead = `checkBox -q -v $fcfnCheckName`; if ($fcfnCheckRead==0) { fCreateCurve($fcfnLength, $fcfnNSpans, $fcfnname); } fLoopCreate($fcfnname,$fcfnCheckNormal); } global proc pickName(string $fcfnname, string $fcfnCheckName) { global string $fcfnname; int $fCheckN = `checkBox -q -value $fcfnCheckName`; if ($fCheckN == 1) { string $fcfnnewNameObjs[] = `ls -sl`; if (`size $fcfnnewNameObjs` == 1) { string $fcfnnewName = $fcfnnewNameObjs[0]; string $fABCtest = `match "[0-9]" $fcfnnewName`; if ($fABCtest == "") { textField -e -text $fcfnnewName $fcfnname; } else { textField -e -text "" $fcfnname; error "name [0-9]"; } } else { textField -e -text "" $fcfnname; error "???"; } } } global proc fCreateCurve(string $fcfnLength, string $fcfnNSpans, string $fcfnname) { string $fcfnnextSel[] = `ls -sl`; float $fcfnLengthC = `floatField -q -value $fcfnLength`; int $fcfnNSpansC = `intField -q -value $fcfnNSpans`; global string $fcfnnameCobj; string $fcfnnameCobj = `textField -q -text $fcfnname`; $fcfnNSpansC = $fcfnNSpansC - 1; float $fcfnCurvPart = $fcfnLengthC/$fcfnNSpansC; string $fcfncurveP = ""; float $fcfni = 0; while ($fcfni <= $fcfnLengthC) { $fcfncurveP = ($fcfncurveP+"-p 0 "+$fcfni+" 0 "); $fcfni = $fcfni + $fcfnCurvPart; } $fcfncurveP = ("curve -d 3 "+$fcfncurveP+";"); eval $fcfncurveP; rename $fcfnnameCobj; select $fcfnnextSel; } global proc fLoopCreate(string $fcfnname,string $fcfnCheckNormal) { global int $fcfnCheckReadN; int $fcfnCheckReadN = `checkBox -q -v $fcfnCheckNormal`; string $fcfnnameCobj = `textField -q -text $fcfnname`; string $fcfnSelComp[] = `ls -sl -fl`; string $fcfnforComp; for ($fcfnforComp in $fcfnSelComp) { select $fcfnforComp; fXYZread($fcfnforComp,$fcfnnameCobj); } if ($fcfnCheckReadN == 1) { string $fcfnnameCobjN = ($fcfnnameCobj+"*"); select $fcfnnameCobjN; string $fcfnselCons[] = `ls -sl -as -g $fcfnnameCobjN`; select -d $fcfnselCons; doDelete; } global int $fcfnCheckRead; if ($fcfnCheckRead==0) { select $fcfnnameCobj; doDelete; } select $fcfnSelComp; } global proc fXYZread(string $fcfnforComp,string $fcfnnameCobj) { float $fcfnXYZ[] = `xform -q -ws -t`; int $fcfnsize= `size $fcfnXYZ`; int $fcfnsize_p= $fcfnsize/3; int $fcfnzero = 0; string $fcfnxReZ = ""; while ($fcfnzero < $fcfnsize) { string $fcfnpart = ("$fcfnXYZ["+$fcfnzero+"]+"); $fcfnxReZ = ($fcfnxReZ+$fcfnpart); $fcfnzero = $fcfnzero +3; if ($fcfnzero>=($fcfnsize-1)) { $fcfnzero=1; string $fcfnyReZ = ""; while ($fcfnzero < $fcfnsize) { $fcfnpart = ("$fcfnXYZ["+$fcfnzero+"]+"); $fcfnyReZ = ($fcfnyReZ+$fcfnpart); $fcfnzero = $fcfnzero +3; if ($fcfnzero>=($fcfnsize-1)) { $fcfnzero=2; string $fcfnzReZ = ""; while ($fcfnzero < $fcfnsize) { $fcfnpart = ("$fcfnXYZ["+$fcfnzero+"]+"); $fcfnzReZ = ($fcfnzReZ+$fcfnpart); $fcfnzero = $fcfnzero +3; if ($fcfnzero>=($fcfnsize)) fEditorText($fcfnxReZ,$fcfnyReZ,$fcfnzReZ,$fcfnsize_p,$fcfnXYZ,$fcfnforComp,$fcfnnameCobj); } } } } } } global proc fEditorText(string $fcfnxReZ,string $fcfnyReZ,string $fcfnzReZ, int $fcfnsize_p, float $fcfnXYZ[],string $fcfnforComp,string $fcfnnameCobj) { $fcfnxReZ=startString ($fcfnxReZ,`size $fcfnxReZ`-1); $fcfnxReZ=("float $fcfnXYZ[] = `xform -q -ws -t`; float $fcfnvx = ("+$fcfnxReZ+")/"+$fcfnsize_p+";"); $fcfnyReZ=startString ($fcfnyReZ,`size $fcfnyReZ`-1); $fcfnyReZ=("float $fcfnXYZ[] = `xform -q -ws -t`; float $fcfnvy = ("+$fcfnyReZ+")/"+$fcfnsize_p+";"); $fcfnzReZ=startString ($fcfnzReZ,`size $fcfnzReZ`-1); $fcfnzReZ=("float $fcfnXYZ[] = `xform -q -ws -t`;float $fcfnvz = ("+$fcfnzReZ+")/"+$fcfnsize_p+";"); float $fcfnrx = `eval $fcfnxReZ`; float $fcfnry = `eval $fcfnyReZ`; float $fcfnrz = `eval $fcfnzReZ`; select $fcfnnameCobj; global string $fcfnCheckInstance; int $fTestIns = `checkBox -q -v $fcfnCheckInstance`; if ($fTestIns) {instance;} else {duplicate;} move -a $fcfnrx $fcfnry $fcfnrz; string $fcfnForConstrain[] = `ls -sl`; select $fcfnforComp; select -add $fcfnForConstrain; global int $fcfnCheckReadN; if ($fcfnCheckReadN == 1) { geometryConstraint -weight 1; normalConstraint -weight 1 -aimVector 0 1 0 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0; } } ////////////////////////////// global proc fSelectEdgeLoopPart() { print "fSelectEdgeLoopPart;\n"; SelectEdgeLoop; string $fStartSel[] = `ls -sl -fl`; PolySelectTraverse 1; string $fStartSelTr[] = `ls -sl -fl`; select -d $fStartSel; string $fStartSelTrD[] = `ls -sl -fl`; select $fStartSel; ConvertSelectionToFaces; string $fStartSelFF[] = `ls -sl -fl`; PolySelectTraverse 1; select -d $fStartSelFF; ConvertSelectionToEdges; string $fStartSelFT[] = `ls -sl -fl`; select $fStartSelTrD; select -d $fStartSelFT; string $fStartSelNead[] = `ls -sl -fl`; select $fStartSelNead[0]; for ($i = 1; $i > 0; $i++) { string $FfistN[] = `ls -sl -fl`; fNextRingEdgeSelect; select -d $fStartSelFT; string $FnextN[] = `ls -sl -fl`; int $fFist = `size $FfistN`; int $fNext = `size $FnextN`; if ($fFist == $fNext) break; } ConvertSelectionToFaces; string $fGran[] = `ls -sl -fl`; select -tgl $fStartSelFF; for ($i = 1; $i > 0; $i++) { string $FfistN[] = `ls -sl -fl`; PolySelectTraverse 1; select -d $fGran; string $FnextN[] = `ls -sl -fl`; int $fFist = `size $FfistN`; int $fNext = `size $FnextN`; if ($fFist == $fNext) break; } string $FfistN[] = `ls -sl -fl`; fSelectShell; select -d $FfistN; string $FnextN[] = `ls -sl -fl`; int $fFist = `size $FfistN`; int $fNext = `size $FnextN`; if ($fFist < $fNext) {select $FfistN;} else {select $FnextN;} } /////////////////////////mat global proc fMatFace() { print "fMatFace;\n"; ConvertSelectionToFaces; string $fStartFaceSel[] = `ls -sl -fl`;; string $fAllMat[] = `ls -mat -fl`; int $fCheckSizeMat = `size $fAllMat`; progressWindow -title "Select Material" -progress 0 -max $fCheckSizeMat -status "Start" -isInterruptable true; global string $fFinalListMat[]; $fFinalListMat = {}; string $fOneMat; int $fComp = 1; for ($fOneMat in $fAllMat) { if ( `progressWindow -query -isCancelled` ) break; global string $fFinalListMat[]; hyperShade -objects $fOneMat; ConvertSelectionToFaces; string $fTestF[] = `ls -sl -fl`; string $fTestN[] = stringArrayRemove($fStartFaceSel, $fTestF); int $fSizeF = `size $fTestF`; int $fSizeN = `size $fTestN`; if ($fSizeN<$fSizeF) { global string $fFinalListMat[]; $fFinalListMat[(`size $fFinalListMat`)] = $fOneMat; } progressWindow -edit -progress $fComp -status ("Searching: "+$fComp); $fComp = $fComp +1; } select -cl; select $fFinalListMat; progressWindow -endProgress; $fFinalListMat = {}; } global proc fMatUnused() { print "fMatUnused;\n"; select -cl; string $fAllMat[] = `ls -mat -fl`; int $fCheckSizeMat = `size $fAllMat`; progressWindow -title "Select Material" -progress 0 -max $fCheckSizeMat -status "Start" -isInterruptable true; global string $fFinalListMat[]; $fFinalListMat = {}; string $fOneMat; int $fComp = 1; for ($fOneMat in $fAllMat) { if ( `progressWindow -query -isCancelled` ) break; global string $fFinalListMat[]; hyperShade -objects $fOneMat; string $fTestF[] = `ls -sl -fl`; int $fSizeF = `size $fTestF`; if ($fSizeF==0) { global string $fFinalListMat[]; $fFinalListMat[(`size $fFinalListMat`)] = $fOneMat; } progressWindow -edit -progress $fComp -status ("Searching: "+$fComp); $fComp = $fComp +1; } select -cl; select $fFinalListMat; progressWindow -endProgress; $fFinalListMat = {}; } /////////////////////// mirror global proc fMirFace(float $xVal, float $yVal, float $zVal) { string $fStartObj[]=`ls -sl -fl`; ConvertSelectionToVertices; string $fStartVert[]=`ls -sl -fl`; global float $fXcenter; global float $fYcenter; global float $fZcenter; float $fAllFloat[] = `xform -q -t -ws`; int $fSizeF = `size $fAllFloat`; float $fTestFloat[] = {}; int $fI=0; while ($fI<$fSizeF) { $fTestFloat[`size $fTestFloat`] = $fAllFloat[$fI]; $fI = $fI + 3; if ($fI>=$fSizeF) { global float $fXcenter; $fXcenter = `fSearchCenterValue($fTestFloat)`; } } float $fTestFloat[] = {}; int $fI=1; while ($fI<$fSizeF) { $fTestFloat[`size $fTestFloat`] = $fAllFloat[$fI]; $fI = $fI + 3; if ($fI>=$fSizeF) { global float $fYcenter; $fYcenter = `fSearchCenterValue($fTestFloat)`; } } float $fTestFloat[] = {}; int $fI=2; while ($fI<$fSizeF) { $fTestFloat[`size $fTestFloat`] = $fAllFloat[$fI]; $fI = $fI + 3; if ($fI>=$fSizeF) { global float $fZcenter; $fZcenter = `fSearchCenterValue($fTestFloat)`; } } scale -r -p $fXcenter $fYcenter $fZcenter $xVal $yVal $zVal; polyNormal -normalMode 0 -ch 1; select $fStartObj; } global proc float fSearchCenterValue(float $fSNeadFArray[]) { int $fin = `size $fSNeadFArray`; float $fCenter = 0; for ($i = 0; $i <= ($fin-1); $i++) { float $fCenter = ($fCenter + $fSNeadFArray[$i]); if ($i==($fin-1)) {$fCenter = ($fCenter/$fin); return$fCenter;} } } global proc fMirShape(float $xVal, float $yVal, float $zVal) { string $fStartObj[]=`ls -sl -fl`; select `ls -sl -fl -o`; ConvertSelectionToVertices; scale -r -ocp $xVal $yVal $zVal; polyNormal -normalMode 0 -ch 1; select $fStartObj; hilite -r `ls -sl -fl -o`; } /////////////////// ABS global proc fLWfit() { global string $fAbsX; global string $fAbsY; global string $fAbsZ; if (`window -exists fTranslate`) deleteUI fTranslate; string $fStartOBJsel[] = `ls -sl -fl`; float $fLocalOSTr[]; if (`size $fStartOBJsel` == 1) $fLocalOSTr = `xform -q -t -os`; float $fRealPiv[]; if (`size $fStartOBJsel` == 1) $fRealPiv = `xform -q -piv -ws`; if (`size $fStartOBJsel` != 1) $fRealPiv={}; string $fTitleA; if (`size $fStartOBJsel` != 1) $fTitleA = "Absolute Move"; if (`size $fStartOBJsel` == 1) $fTitleA = $fStartOBJsel[0]; string $fTwindow = `window -t $fTitleA fTranslate`; columnLayout -adjustableColumn true; setParent ..; if (`size $fStartOBJsel` == 1) { rowLayout -numberOfColumns 4 -columnWidth4 100 80 80 80 -columnAlign 1 "left" -columnAlign 2 "center" -columnAlign 3 "center" -columnAlign 4 "center"; text -l "Local Translate:";text -l $fLocalOSTr[0];text -l $fLocalOSTr[1];text -l $fLocalOSTr[2]; setParent ..; separator -style "single"; rowLayout -numberOfColumns 4 -columnWidth4 100 80 80 80 -columnAlign 1 "left" -columnAlign 2 "center" -columnAlign 3 "center" -columnAlign 4 "center"; text -l "World Translate:";text -l $fRealPiv[0];text -l $fRealPiv[1];text -l $fRealPiv[2]; setParent ..; separator -style "single"; separator -style "none"; } rowLayout -numberOfColumns 4 -columnWidth4 100 80 80 80 -columnAlign 1 "center" -columnAlign 2 "center" -columnAlign 3 "center" -columnAlign 4 "center"; button -l "Reload" -w 100 -c "fLWfit;"; global string $fAbsX; string $fAbsX = `floatField -v $fRealPiv[0] -w 70`; global string $fAbsY; string $fAbsY = `floatField -v $fRealPiv[1] -w 70`; global string $fAbsZ; string $fAbsZ = `floatField -v $fRealPiv[2] -w 70`; setParent ..; rowLayout -numberOfColumns 4 -columnWidth4 100 80 80 80 -columnAlign 1 "center" -columnAlign 2 "center" -columnAlign 3 "center" -columnAlign 4 "center"; button -l "Absolute Move" -w 100 -c "move -rpr -spr `floatField -q -v $fAbsX` `floatField -q -v $fAbsY` `floatField -q -v $fAbsZ`;fLWfit;"; button -l "X" -w 70 -c "move -rpr -spr -x `floatField -q -v $fAbsX`;fLWfit;"; button -l "Y" -w 70 -c "move -rpr -spr -y `floatField -q -v $fAbsY`;fLWfit;"; button -l "Z" -w 70 -c "move -rpr -spr -z `floatField -q -v $fAbsZ`;fLWfit;"; setParent ..; text -l "For Pivot:"; rowLayout -numberOfColumns 4 -columnWidth4 100 80 80 80 -columnAlign 1 "center" -columnAlign 2 "center" -columnAlign 3 "center" -columnAlign 4 "center"; button -l "Pivot" -w 100 -c "move -rpr -spr `floatField -q -v $fAbsX` `floatField -q -v $fAbsY` `floatField -q -v $fAbsZ` .scalePivot .rotatePivot;fLWfit;"; button -l "X" -w 70 -c "string $fSelTest[] = `ls -sl -fl`; if (`size $fSelTest` == 1) {move -rpr -spr -x `floatField -q -v $fAbsX`;fLWfit;Undo;move -rpr -spr `floatField -q -v $fAbsX` `floatField -q -v $fAbsY` `floatField -q -v $fAbsZ` .scalePivot .rotatePivot;fLWfit;} else {error \"Select one obj\";}"; button -l "Y" -w 70 -c "string $fSelTest[] = `ls -sl -fl`; if (`size $fSelTest` == 1) {move -rpr -spr -y `floatField -q -v $fAbsY`;fLWfit;Undo;move -rpr -spr `floatField -q -v $fAbsX` `floatField -q -v $fAbsY` `floatField -q -v $fAbsZ` .scalePivot .rotatePivot;fLWfit;} else {error \"Select one obj\";}"; button -l "Z" -w 70 -c "string $fSelTest[] = `ls -sl -fl`; if (`size $fSelTest` == 1) {move -rpr -spr -z `floatField -q -v $fAbsZ`;fLWfit;Undo;move -rpr -spr `floatField -q -v $fAbsX` `floatField -q -v $fAbsY` `floatField -q -v $fAbsZ` .scalePivot .rotatePivot;fLWfit;} else {error \"Select one obj\";}"; setParent ..; showWindow $fTwindow; } global proc fLWfitVertex() { global string $fAbsX; global string $fAbsY; global string $fAbsZ; if (`window -exists fTranslate`) deleteUI fTranslate; string $fStartOBJsel[] = `ls -sl -fl`; float $fLocalOSTr[]; if (`size $fStartOBJsel` == 1) $fLocalOSTr = `xform -q -t -os`; float $fRealPiv[]; if (`size $fStartOBJsel` == 1) $fRealPiv = `xform -q -t -ws`; if (`size $fStartOBJsel` != 1) $fRealPiv={}; string $fTitleA; if (`size $fStartOBJsel` != 1) $fTitleA = "Absolute Move"; if (`size $fStartOBJsel` == 1) $fTitleA = $fStartOBJsel[0]; string $fTwindow = `window -t ($fTitleA+" (for vertex)") fTranslate`; columnLayout -adjustableColumn true; setParent ..; if (`size $fStartOBJsel` == 1) { rowLayout -numberOfColumns 4 -columnWidth4 100 80 80 80 -columnAlign 1 "left" -columnAlign 2 "center" -columnAlign 3 "center" -columnAlign 4 "center"; text -l "Local Translate:";text -l $fLocalOSTr[0];text -l $fLocalOSTr[1];text -l $fLocalOSTr[2]; setParent ..; separator -style "single"; rowLayout -numberOfColumns 4 -columnWidth4 100 80 80 80 -columnAlign 1 "left" -columnAlign 2 "center" -columnAlign 3 "center" -columnAlign 4 "center"; text -l "World Translate:";text -l $fRealPiv[0];text -l $fRealPiv[1];text -l $fRealPiv[2]; setParent ..; separator -style "single"; separator -style "none"; } rowLayout -numberOfColumns 4 -columnWidth4 100 80 80 80 -columnAlign 1 "center" -columnAlign 2 "center" -columnAlign 3 "center" -columnAlign 4 "center"; button -l "Reload" -w 100 -c "fLWfitVertex;"; global string $fAbsX; string $fAbsX = `floatField -v $fRealPiv[0] -w 70`; global string $fAbsY; string $fAbsY = `floatField -v $fRealPiv[1] -w 70`; global string $fAbsZ; string $fAbsZ = `floatField -v $fRealPiv[2] -w 70`; setParent ..; rowLayout -numberOfColumns 4 -columnWidth4 100 80 80 80 -columnAlign 1 "center" -columnAlign 2 "center" -columnAlign 3 "center" -columnAlign 4 "center"; button -l "Absolute Move" -w 100 -c "move -rpr -spr `floatField -q -v $fAbsX` `floatField -q -v $fAbsY` `floatField -q -v $fAbsZ`;fLWfitVertex;"; button -l "X" -w 70 -c "move -rpr -spr -x `floatField -q -v $fAbsX`;fLWfitVertex;"; button -l "Y" -w 70 -c "move -rpr -spr -y `floatField -q -v $fAbsY`;fLWfitVertex;"; button -l "Z" -w 70 -c "move -rpr -spr -z `floatField -q -v $fAbsZ`;fLWfitVertex;"; setParent ..; showWindow $fTwindow; } //////////////////////// Calculator global proc fCalculator() { print "fCalculator;\n"; if (`window -exists fCalculator`) deleteUI fCalculator; string $fCalc = `window -mxb 0 -t "Calculator" fCalculator`; columnLayout -adjustableColumn true; setParent ..; rowLayout -numberOfColumns 3 -columnWidth3 250 50 100 -columnAlign 1 "left" -columnAlign 2 "center" -columnAlign 3 "center"; global string $fForCalc; string $fForCalc = `textField -w 250 -ann "(1+5)*6"`; button -l "=" -w 50 -c "fCalc;"; global string $fForCalcRes; string $fForCalcRes = `floatField -w 100`; setParent ..; showWindow $fCalc; } global proc fCalc() { global string $fForCalc; global string $fForCalcRes; string $fForEvalCalc = `textField -q -text $fForCalc`; float $fCalcRes = `eval ("float $fTestCalc = "+$fForEvalCalc)`; floatField -e -v $fCalcRes $fForCalcRes; print (`textField -q -text $fForCalc`+" = "+ $fCalcRes+"\n"); } /////////////////freeze global proc fKillFreeze() { print "fKillFreeze;\n"; string $fStartObj[] = `ls -sl -fl -o`; string $fForKillObj; for ($fForKillObj in $fStartObj) { select $fForKillObj; string $fGTest[] = `listRelatives -allParents $fForKillObj`; if (`size $fGTest` != 0) parent -world ; float $fRealP[] = `xform -q -ws -piv`; move -rpr -spr 0 0 0; makeIdentity -apply true -t 1 -r 0 -s 0 -n 0; move -rpr -spr $fRealP[0] $fRealP[1] $fRealP[2]; } select $fStartObj; } ///////////////////// global proc fPixelMove() { if (`window -exists fPMove`) deleteUI fPMove; string $fWindowPixel = `window -title "Pixel Move" -s 0 fPMove`; columnLayout -adjustableColumn true; setParent ..; rowLayout -numberOfColumns 3 -columnWidth3 35 35 35 -columnAlign 1 "center" -columnAlign 2 "center" -columnAlign 3 "center"; button -l "" -w 35 -h 35 -c "fPixelMover(-1,1);"; button -l "" -w 35 -h 35 -c "fPixelMover(0,1);"; button -l "" -w 35 -h 35 -c "fPixelMover(1,1);"; setParent ..; rowLayout -numberOfColumns 3 -columnWidth3 35 35 35 -columnAlign 1 "center" -columnAlign 2 "center" -columnAlign 3 "center"; button -l "" -w 35 -h 35 -c "fPixelMover(-1,0);"; global string $fForPixelMove; $fForPixelMove = `intField -v 1 -w 35 -h 35`; button -l "" -w 35 -h 35 -c "fPixelMover(1,0);"; setParent ..; rowLayout -numberOfColumns 3 -columnWidth3 35 35 35 -columnAlign 1 "center" -columnAlign 2 "center" -columnAlign 3 "center"; button -l "" -w 35 -h 35 -c "fPixelMover(-1,-1);"; button -l "" -w 35 -h 35 -c "fPixelMover(0,-1);"; button -l "" -w 35 -h 35 -c "fPixelMover(1,-1);"; setParent ..; showWindow $fWindowPixel; } global proc fPixelMover(int $fPixelX, int $fPixelY) { global string $fForPixelMove; int $fPixels = `intField -q -v $fForPixelMove`; int $i; for ($i = $fPixels; $i > 0; $i--) { pixelMove $fPixelX $fPixelY; } } global proc float[] fWorldObjectPos() { string $fSel[] = `ls -sl -fl`; float $fPos[3]; if (`size $fSel` != 0) { string $mainObject = $fSel[ (`size $fSel` - 1) ]; float $fPosWorld[] = `xform -q -t -ws $mainObject`; $fPos[0] = $fPosWorld[0]; $fPos[1] = $fPosWorld[1]; $fPos[2] = $fPosWorld[2]; } else { $fPos[0] = 0; $fPos[1] = 0; $fPos[2] = 0; } return $fPos; } global proc string fCam() { string $fcam; string $fcam = `getPanel -wf`; string $fcam = `modelPanel -q -cam $fcam`; return $fcam; } global proc float fWorldObjectDis() { string $fSelCam = fCam(); string $fSel[] = `ls -sl -fl`; if (`size $fSel` != 0) { string $mainObject = $fSel[ (`size $fSel` - 1) ]; float $fPosWorld[] = `xform -q -t -ws $mainObject`; float $fPosWorldCam[] = `xform -q -piv -ws $fSelCam`; vector $fVecF = {$fPosWorldCam[0], $fPosWorldCam[1],$fPosWorldCam[2]}; vector $fVecN = {$fPosWorld[0], $fPosWorld[1],$fPosWorld[2]}; vector $fResVec = $fVecF - $fVecN; float $fFinal = mag($fResVec); return $fFinal; } else { float $fFinal = 0; return $fFinal; } } global proc fDisFromCamUI() { float $fWorldPos[] = fWorldObjectPos(); float $fCameraDist = fWorldObjectDis(); if (`window -exists fDistFromCam`) deleteUI fDistFromCam; string $fDistWnd = `window -title "Distance From Camera (for vertex)" -s 0 fDistFromCam`; columnLayout -adjustableColumn true; floatFieldGrp -numberOfFields 3 -label "World Position" -value1 $fWorldPos[0] -value2 $fWorldPos[1] -value3 $fWorldPos[2]; floatFieldGrp -numberOfFields 1 -label "Distance From Camera" -value1 $fCameraDist ; button -label "Repeat" -c "fDisFromCamUI();"; setParent ..; showWindow $fDistWnd ; print ("Distance From Camera: " + $fCameraDist+"\n"); } global proc fPCountUI() { if (`window -exists fPolyCount`) deleteUI fPolyCount; string $fAllMesh[] = `ls -typ "mesh" -fl`; if (`size $fAllMesh` == 0) error "No Poly Mesh"; int $fAllTCount[] = `polyEvaluate -t $fAllMesh`; int $fAllFCount[] = `polyEvaluate -f $fAllMesh`; int $fAllVCount[] = `polyEvaluate -v $fAllMesh`; int $fAllUVCount[] = `polyEvaluate -uv $fAllMesh`; string $fPolyCount = `window -title "Poly Count" -s 0 fPolyCount`; columnLayout -adjustableColumn true; setParent ..; rowColumnLayout -numberOfColumns 2 -cw 1 120; text -l "Number Of Triangles: " -align "right"; intField -v $fAllTCount[0]; ; text -l "Number Of Faces: " -align "right"; intField -v $fAllFCount[0]; ; text -l "Number Of Vertices: " -align "right"; intField -v $fAllVCount[0]; ; text -l "Number Of UV: " -align "right"; intField -v $fAllUVCount[0]; ; setParent ..; columnLayout -adjustableColumn true; button -l "Reload" -c "fPCountUI"; setParent ..; showWindow $fPolyCount; } global proc fBBSizeUI() { if (`window -exists fBBSizeWind`) deleteUI fBBSizeWind; string $fBBSize[] = `ls -fl -typ "mesh"`; if (`size $fBBSize` == 0) error "No Obj"; float $fBBSizeRead[] = `polyEvaluate -b $fBBSize`; float $fBBSizeX = abs($fBBSizeRead[0]-$fBBSizeRead[1]); float $fBBSizeY = abs($fBBSizeRead[2]-$fBBSizeRead[3]); float $fBBSizeZ = abs($fBBSizeRead[4]-$fBBSizeRead[5]); float $fBBradius = `max $fBBSizeX $fBBSizeY`; float $fBBradius = `max $fBBradius $fBBSizeZ`; string $fBBSizeW= `window -title "Bounding Box Size" -s 0 fBBSizeWind`; columnLayout -adjustableColumn true; setParent ..; rowColumnLayout -numberOfColumns 2 -cw 1 60; text -l "Size X: " -align "right"; floatField -v $fBBSizeX; text -l "Size Y: " -align "right"; floatField -v $fBBSizeY; ; text -l "Size Z: " -align "right"; floatField -v $fBBSizeZ; setParent ..; columnLayout -adjustableColumn true; separator -style "none"; setParent ..; rowColumnLayout -numberOfColumns 2 -cw 1 60; text -l "Radius: " -align "right"; floatField -v ($fBBradius/2); setParent ..; columnLayout -adjustableColumn true; button -l "Reload" -c "fBBSizeUI"; setParent ..; showWindow $fBBSizeW; } global proc fFitToEdgeLine() { global string $fResTwoVert[]; $fResTwoVert = {}; string $StartEdgeSel[] = `ls -sl -fl`; ConvertSelectionToVertices; string $StartVertSel[] = `ls -sl -fl`; string $fForVert; for ($fForVert in $StartVertSel) { select $fForVert; PolySelectTraverse 1; string $Prover[] = `ls -sl -fl`; string $Prover2[] = $StartVertSel; int $SizeProver = `size $Prover2`; string $Prover[] = stringArrayRemove($Prover, $Prover2); int $SizeProver2 = `size $Prover`; int $Res = abs($SizeProver2 - $SizeProver); if ($Res == 2) { global string $fResTwoVert[]; $fResTwoVert[`size $fResTwoVert`] = $fForVert; } } if (`size $fResTwoVert`>2) {select -cl;error "???";} select $fResTwoVert; float $fCurveXf[] = `xform -q -t -ws`; curve -d 1 -p $fCurveXf[0] $fCurveXf[1] $fCurveXf[2] -p $fCurveXf[3] $fCurveXf[4] $fCurveXf[5] -n "fHELPfLINE" ; for ($fForVert in $StartVertSel) { select $fForVert; float $fNeadXform[] = `xform -q -t -ws`; spaceLocator -n "fHELPfLINEloc"; move $fNeadXform[0] $fNeadXform[1] $fNeadXform[2]; select "fHELPfLINE" "fHELPfLINEloc"; geometryConstraint -weight 1; select "fHELPfLINEloc"; float $fNeadXform[] = `xform -q -t -ws`; select $fForVert; move -rpr -spr $fNeadXform[0] $fNeadXform[1] $fNeadXform[2]; delete "fHELPfLINEloc"; } delete "fHELPfLINE"; select $StartEdgeSel; hilite -r `ls -sl -o`; } global proc fMentalSSS(string $fShaderName) { string $fShaderSSS = `mrCreateCustomNode -asShader "" $fShaderName`; string $fListSG[] = `listConnections ($fShaderSSS + ".message")`; string $fShaderLM = `mrCreateCustomNode -asUtility "" misss_fast_lmap_maya`; mentalrayTextureNodeCreate ($fShaderLM + ".lightmap"); string $fShaderLmW[] = `listConnections ($fShaderLM + ".lightmap")`; connectAttr -f ($fShaderLM + ".message") ($fListSG[0]+".miLightMapShader"); connectAttr -f ($fShaderLmW[0] + ".message") ($fShaderSSS + ".lightmap"); setAttr ($fShaderLmW[0] + ".miWritable") 1; setAttr ($fShaderLmW[0] + ".miDepth") 4; expression -s ($fShaderLmW[0]+".miWidth = defaultResolution.width*2;"+$fShaderLmW[0]+".miHeight = defaultResolution.height;") -o $fShaderLmW[0] -n ("exp_"+$fShaderSSS); select $fShaderSSS; } /////////////////////////////////////// Utils global proc fShowFreeMemory() { if (`headsUpDisplay -ex fShowMemory`) { headsUpDisplay -rem fShowMemory; } else { headsUpDisplay -section 0 -block 7 -blockSize "small" -label "Free Memory:" -labelFontSize "small" -command "fFreeMemory()" -attachToRefresh fShowMemory; } } global proc float fFreeMemory() { float $fFree[] = `memory -fr`; return $fFree[0]; } global proc fClearUndo() { undoInfo -state off; undoInfo -state on; } global proc fShowFrame() { if (`headsUpDisplay -ex fShowFrame`) { headsUpDisplay -rem fShowFrame; } else { headsUpDisplay -section 0 -block 8 -blockSize "small" -label "Frame:" -labelFontSize "small" -command "fFrameScene()" -attachToRefresh fShowFrame; } } global proc float fFrameScene() { float $fFrame = `currentTime -q`; return $fFrame; } global proc fKillInstance() { print "fKillInstance;\n"; string $StartSelAll[]=`ls -sl -fl`; string $forOne; for ($forOne in $StartSelAll) { select $forOne; duplicate; delete $forOne; rename $forOne; } select $StartSelAll; } global proc fForeach() { if (`window -exists fForeachUI`) {deleteUI fForeachUI;} string $window = `window -title "Foreach" -iconName "Foreach" -w 320 fForeachUI`; columnLayout -adjustableColumn true; text -l "Command:"; global string $fForeachCommand; $fForeachCommand = `textField`; button -l "do" -c "fForeachDo;"; button -l "Add Command" -c "fAddCommand;"; button -l "listAttr -k" -c "fListAttr"; setParent ..; showWindow $window; } global proc fForeachDo() { string $fAllSel[] = `ls -sl -fl`; if (`size $fAllSel`==0) error "Nothing selected"; global string $fForeachCommand; string $fReadField = `textField -q -tx $fForeachCommand`; string $fForOne; for ($fForOne in $fAllSel) { select $fForOne; eval $fReadField; } select $fAllSel; } global proc fListAttr() { string $fNameSNode[] = `ls -sl -fl`; if (`size $fNameSNode`==0) error "Nothing selected"; if (`window -exists fAttrsUI`) {deleteUI fAttrsUI;} string $fSelAttr[] = `listAttr -k`; string $fForOne; string $windowAttr = `window -title "listAttr" -iconName "listAttr" -w 250 -h 250 fAttrsUI`; scrollLayout; columnLayout -adjustableColumn true; for ($fForOne in $fSelAttr) { textField -tx ($fNameSNode[0]+"."+$fForOne) -w 200; } setParent ..; showWindow $windowAttr ; } global proc fAddCommand() { if (`window -exists fListCommandsUI`) {deleteUI fListCommandsUI;} string $windowC = `window -title "Commands" -iconName "Commands" -w 150 fListCommandsUI`; columnLayout -adjustableColumn true; button - l "rand" -c "fAddCommandText(\"rand \");"; button - l "clamp" -c "fAddCommandText(\"clamp ? ? ? \");"; button - l "abs" -c "fAddCommandText(\"abs \");"; button - l "ceil" -c "fAddCommandText(\"ceil \");"; button - l "floor" -c "fAddCommandText(\"floor \");"; button - l "trunc" -c "fAddCommandText(\"trunc \");"; button - l "sqrt" -c "fAddCommandText(\"sqrt \");"; button - l "pow" -c "fAddCommandText(\"pow ? ? \");"; separator -style "none"; separator -style "single"; separator -style "none"; button - l "getAttr" -c "fAddCommandText(\"getAttr .? \");"; button - l "setAttr" -c "fAddCommandText(\"setAttr .? ? \");"; button - l "moveVertexAlongDirection" -c "fAddCommandText(\"moveVertexAlongDirection -n ?\");"; showWindow $windowC ; } global proc fAddCommandText(string $fText) { global string $fForeachCommand; string $fReadField = `textField -q -tx $fForeachCommand`; $fReadField = ($fReadField + $fText); textField -e -tx $fReadField $fForeachCommand; } global proc fEdgeLoopPartSel() { string $fStartEdge[] = `ls -sl -fl`; if (`size $fStartEdge` != 2) error "only for two edge"; select $fStartEdge[0]; { SelectEdgeLoop; string $fTestEdge[] = `ls -sl -fl`; fSelectObjBorder; select -add $fTestEdge; string $fTestEdge[] = `ls -sl -fl`; int $fSizeOne = `size $fTestEdge`; select -d $fStartEdge[1]; string $fTestEdge[] = `ls -sl -fl`; int $fSizeTwo = `size $fTestEdge`; if ($fSizeOne==$fSizeTwo) error "Edge Loop not Found"; } select $fStartEdge[0]; for ($i = 1; $i > 0; $i++) { fNextLoopEdgeSelect; string $fNEdge[] = `ls -sl -fl`; int $fFsize = `size $fNEdge`; select -d $fStartEdge[1]; string $fNNEdge[] = `ls -sl -fl`; int $fNsize = `size $fNNEdge`; if ($fFsize > $fNsize) {select -add $fStartEdge[1]; break;} } string $fFEdge[] = `ls -sl -fl`; select $fStartEdge[1]; for ($i = 1; $i > 0; $i++) { fNextLoopEdgeSelect; string $fNEdge[] = `ls -sl -fl`; int $fFsize = `size $fNEdge`; select -d $fStartEdge[0]; string $fNNEdge[] = `ls -sl -fl`; int $fNsize = `size $fNNEdge`; if ($fFsize > $fNsize) {select -add $fStartEdge[0]; break;} } string $fNEdge[] = `ls -sl -fl`; select -tgl $fFEdge; string $fNNEdge[] = `ls -sl -fl`; select $fFEdge; select -d $fNNEdge; string $fStartEdge[] = `ls -sl -fl`; select $fStartEdge[0]; for ($i = 1; $i > 0; $i++) { string $fNEdge[] = `ls -sl -fl`; int $fFsize = `size $fNEdge`; PolySelectTraverse 1; string $fNNEdge[] = `ls -sl -fl`; select -d $fStartEdge; select -tgl $fNNEdge; string $fNNEdge[] = `ls -sl -fl`; int $fNsize = `size $fNNEdge`; if ($fFsize == $fNsize) break; } string $fNextEdge[] = `ls -sl -fl`; int $fS = `size $fStartEdge`; int $fN = `size $fNextEdge`; if ($fS != $fN) { select -tgl $fStartEdge; string $fNextNextEdge[] = `ls -sl -fl`; int $fNN = `size $fNextNextEdge`; if ($fNN<$fN) select $fNextEdge; } } //////////////////// FNDAverage global proc FNDAverage(int $nSmooth, string $inter, string $subd, string $FNDUndo, string $FNDHis) { int $UndoR = `checkBox -q -v $FNDUndo`; int $HisR = `checkBox -q -v $FNDHis`; if ($UndoR==0) {undoInfo -state off;} int $IntInt = `intField -q -value $inter`; int $IntSds = `intField -q -value $subd`; ConvertSelectionToVertices; string $startVertex[] = `ls -sl -fl`; SelectToggleMode; if ($HisR==1) {DeleteHistory;} string $startObj[] = `ls -sl -fl`; duplicate; if ($nSmooth==1) {polySmooth -mth 1 -dv 1 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl $IntSds -dpe 1 -ps 1 -ro 1 -ch 0 ;} if ($nSmooth==2) {polySmooth -mth 0 -dv $IntSds -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 2 -dpe 1 -ps 1 -ro 1 -ch 0 ;} string $dupObj[] = `ls -sl -fl`; select $startVertex; int $i; for ($i = $IntInt; $i > 0; $i--) { polyAverageVertex -i 18 -ch 0; } string $forVertex; for ($forVertex in $startVertex) { select $forVertex; vector $xform = `xform -ws -q -t`; spaceLocator -n "FNDHelper"; move -ws ($xform.x) ($xform.y) ($xform.z); select $dupObj[0] "FNDHelper"; geometryConstraint -weight 1; select "FNDHelper"; vector $xform = `xform -ws -q -t`; doDelete; select $forVertex; move -ws ($xform.x) ($xform.y) ($xform.z); } delete $dupObj[0]; SelectVertexMask; hilite $startObj[0]; select $startVertex; if ($UndoR==0) {undoInfo -state on;} } global proc FNDVAverage() { if (`window -exists FNDVAverage`) {deleteUI FNDVAverage;} string $window = `window -title "Vertex Average" -iconName "VAverage" FNDVAverage`; columnLayout -adjustableColumn true; setParent ..; rowColumnLayout -numberOfColumns 2; text -label "Iterations:"; global string $FNDIterationsAver; string $FNDIterationsAver = `intField -v 10`; text -label "Subdivision Levels:"; global string $FNDSubdivisionAver; string $FNDSubdivisionAver = `intField -v 2`; global string $FNDUndoV; string $FNDUndoV = `checkBox -l "Undo" -align "left" -v 0`; global string $FNDHisV; string $FNDHisV = `checkBox -l "DeleteHistory" -align "left" -v 1`; button -l "Linear" -c "FNDAverage(1, $FNDIterationsAver, $FNDSubdivisionAver,$FNDUndoV,$FNDHisV); "; button -l "Exponential" -c "FNDAverage(2, $FNDIterationsAver, $FNDSubdivisionAver,$FNDUndoV,$FNDHisV); "; setParent ..; showWindow $window; } /////////////////////new global proc fSelConnEdge() { global string $fFinalConnEdge[]; $fFinalConnEdge = {}; ConvertSelectionToVertices; string $fStartSelVert[] = `ls -sl -fl`; ConvertSelectionToEdges; string $fAllEdge[] = `ls -sl -fl`; string $fForEdge; int $checkSize = `size $fAllEdge`; progressWindow -title "Select Edges" -progress 0 -max $checkSize -status "Start" -isInterruptable 1; int $Comp = 1; for ($fForEdge in $fAllEdge) { if ( `progressWindow -query -isCancelled` ) break; select $fForEdge; ConvertSelectionToVertices; select -d $fStartSelVert; string $fSelVert[] = `ls -sl -fl`; if (`size $fSelVert` == 0) $fFinalConnEdge[`size $fFinalConnEdge`] = $fForEdge; progressWindow -edit -status ($Comp+" ("+$checkSize+")") -progress $Comp; $Comp = $Comp + 1; } //end for in select $fFinalConnEdge; hilite -r `ls -sl -o`; $fFinalConnEdge = {}; progressWindow -endProgress; } //end fSelConnEdge global proc fInvertTopology() { string $fStartObj[] = `ls -sl -fl`; global string $fUVbord[]; $fSaveUv = `confirmDialog -title "InvertTopology" -message "Save Original UV?" -button "Yes" -button "No" -defaultButton "Yes" -cancelButton "No" -dismissString "No"`; if ($fSaveUv == "Yes") { global string $fUVbord[]; ConvertSelectionToUVs; SelectUVBorder; fSelConnEdge; string $fUVbord[] = `ls -sl -fl`; } if ($fSaveUv == "No") {string $fUVbord[] = {};} select $fStartObj; fSelectObjBorder; string $fOBJbord[] = `ls -sl -fl`; select $fStartObj; fHardEdgeSel; string $fAllHard[] = `ls -sl -fl`; select $fStartObj; ConvertSelectionToEdges; string $fAllEdge[] = `ls -sl -fl`; ConvertSelectionToFaces; polyPoke -ch 1; select $fAllEdge; select -d $fOBJbord $fUVbord $fAllHard; DeleteEdge; string $fUVbord[] = {}; } //end fInvertTopology ///////////MIN MAX global proc float[] fValue(int $fTest) { float $fV[] = `xform -q -t -ws`; float $fValue; float $fVr[] = {}; int $fSize = `size $fV`; for ($fValue in $fV) { $fVr[`size $fVr`] = $fV[$fTest]; $fTest = $fTest + 3; if ($fTest >= $fSize) return $fVr; } } global proc fMinMaxMove(int $Test, int $fMinMax ) { float $fVVal[] = `fValue($Test)`; $fVVal= `sort $fVVal`; if ($fMinMax==0) { if ($Test==0) move -x $fVVal[`size $fVVal`-1]; if ($Test==1) move -y $fVVal[`size $fVVal`-1]; if ($Test==2) move -z $fVVal[`size $fVVal`-1]; } else { if ($Test==0) move -x $fVVal[0]; if ($Test==1) move -y $fVVal[0]; if ($Test==2) move -z $fVVal[0]; } } ///////// make clone global proc fMakeClone() { string $fstartObj[] = `ls -sl -o -s -dag`; if (`size $fstartObj` != 1) error "for one obj only"; duplicate; string $fNObj[] = `ls -sl -o -s -dag`; connectAttr -f ($fstartObj[0] + ".outMesh") ($fNObj[0]+".inMesh"); ConvertSelectionToVertices; $fNObj = `ls -sl -fl`; string $forVert; int $checkSize = `size $fNObj` ; progressWindow -title "Make Clone" -progress 0 -max $checkSize -status "Start" -isInterruptable 1; int $Comp = 1; for ($forVert in $fNObj) { if ( `progressWindow -query -isCancelled` ) break; select $forVert; setAttr .pntx 0; setAttr .pnty 0; setAttr .pntz 0; progressWindow -edit -status ($Comp+" ("+$checkSize+")") -progress $Comp; $Comp = $Comp + 1; } progressWindow -endProgress; select `ls -sl -o`; } //select filter global proc int fSelFilter() { if( size(`ls -sl`) == 0 ) error "nothing selected"; if( size( `filterExpand -sm 31` ) != 0 ) { return 1; //vertex } if( size( `filterExpand -sm 32` ) != 0 ) { return 2; //edge } if( size( `filterExpand -sm 34` ) != 0 ) { return 3; //face } if( size( `filterExpand -sm 35` ) != 0 ) { return 4; //uv } return 0; //? (obj) } global proc fVertexLoop() { if (fSelFilter() != 1) error "only for vertex"; ConvertSelectionToContainedEdges; SelectEdgeLoop; ConvertSelectionToVertices; } global proc fFaceBorder() { if (fSelFilter() != 3) error "only for face"; string $fStartFace[] = `ls -sl`; ConvertSelectionToEdges; string $fStartEdge[] = `ls -sl`; select $fStartFace; InvertSelection; ConvertSelectionToEdges; string $fInvertEdge[] = `ls -sl`; select $fStartEdge; select -d $fInvertEdge; string $fInvertEdge[] = `ls -sl`; select $fStartEdge; select -d $fInvertEdge; } // NextEdgeSelect (start) global proc fNextEdgeSelectUI() { if (`window -exists fSelNextTools`) {deleteUI fSelNextTools;} string $window = `window -title "Next Edge Select" -s 0 -iconName "STools" fSelNextTools`; rowColumnLayout -numberOfColumns 2 ; text -label "Steps:"; global string $fNextEdgeSelectSteps; $fNextEdgeSelectSteps = `intField -v 1`; button -label loop -c "fProcNextEdgeSelect(1)"; button -label ring -c "fProcNextEdgeSelect(0)"; setParent ..; showWindow $window; } global proc fNextLoopEdgeSelectFast() { string $fStartEdge[] = `ls -sl -fl`; PolySelectTraverse 1; string $fNExtEdge[] = `ls -sl -fl`; select $fStartEdge; SelectEdgeLoop; string $fLoopEdge[] = `ls -sl -fl`; string $fLast[] = stringArrayRemoveExact($fNExtEdge, $fLoopEdge); string $fLast[] = stringArrayRemoveExact ($fLast,$fLoopEdge); select $fLast; } global proc fNextEdgeSelectLoopCenter(int $case) { //$case = 0; string $StartSelect[] = `ls -sl -fl`; global string $fResTwoVert[]; clear $fResTwoVert; if ($case == 0) SelectEdgeRing; else SelectEdgeLoop; string $StartVertSel[] = `ls -sl -fl`; string $fForVert; for ($fForVert in $StartVertSel) { select $fForVert; if ($case == 0) fNextRingEdgeSelect; else fNextLoopEdgeSelectFast; string $Prover[] = `ls -sl -fl`; string $Prover2[] = $StartVertSel; int $SizeProver = `size $Prover2`; string $Prover[] = stringArrayRemove($Prover, $Prover2); int $SizeProver2 = `size $Prover`; int $Res = abs($SizeProver2 - $SizeProver); if ($Res == 2) { global string $fResTwoVert[]; $fResTwoVert[`size $fResTwoVert`] = $fForVert; } } if (`size $fResTwoVert` != 2) {select $StartSelect;} else select $fResTwoVert; for (;;) { string $Pr1[] = `ls -sl -fl`; if ($case == 0) fNextRingEdgeSelect; else fNextLoopEdgeSelectFast; string $Pr2[] = `ls -sl -fl`; if (size($Pr2)==size($StartVertSel)) {select -d $Pr1; break;} } } global proc fProcNextEdgeSelect( int $case) { if (fSelFilter() != 2) error "only for edge"; global string $fNextEdgeSelectSteps; //int $n = 2; int $n = `intField -q -v $fNextEdgeSelectSteps`; if ($n < 1) error "Staps < 1"; $n = $n*2; //int $case = 1; fNextEdgeSelectLoopCenter($case); global string $fEdges[]; clear $fEdges; for (;;) { global string $fEdges[]; string $startEdge[] = `ls -sl -fl`; if ($case == 0) fNextRingEdgeSelect; else fNextLoopEdgeSelectFast; string $edges[] = `ls -sl -fl`; if (size($edges) == size($startEdge)) break; select -d $startEdge; string $edgeBuffer[] = `ls -sl -fl`; $fEdges = stringArrayCatenate( $fEdges, $edgeBuffer ); select $edges; } global string $fEdgesSel[]; clear $fEdgesSel; int $i = 0; for ($i = 0; $i < `size $fEdges`;) { global string $fEdgesSel[]; global string $fEdges[]; $i = $i + $n - 2; $fEdgesSel[`size $fEdgesSel`] = $fEdges[$i]; ++$i; $fEdgesSel[`size $fEdgesSel`] = $fEdges[$i]; ++$i; $i = $i + $n; } select -cl; for ($i = 0; $i < size($fEdgesSel);++$i) select -add $fEdgesSel[$i]; clear $fEdges; clear $fEdgesSel; } // NextEdgeSelect (END) //short path global proc fShortPath() { if (fSelFilter() != 2) error "only for edge"; global string $fSPedges[]; clear $fSPedges; $fSPedges = `ls -sl -fl`; if (size($fSPedges)!= 2) error "select two edges!"; select $fSPedges[0]; global vector $fTargetEdge; $fTargetEdge = fSelCenterVector(); global float $fAngles[]; clear $fAngles; int $engeCount[] = `polyEvaluate -e`; progressWindow -title ("Count: "+$engeCount[0]) -progress 0 -max ($engeCount[0]/4) -status "Start" -isInterruptable true; for ($z = 0; $z < $engeCount[0]/4; $z++) { if ( `progressWindow -query -isCancelled` ) break; global string $fSPedges[]; global vector $fTargetEdge; select $fSPedges[size($fSPedges)-1]; string $edge[] = `ls -sl -fl`; ConvertSelectionToVertices; string $vertex[] = `ls -sl -fl`; select $edge; PolySelectTraverse 1; select -d $edge; string $nextEdges[] = `ls -sl -fl`; clear $fAngles; progressWindow -edit -progress $z -title ("Short Path") -status ("Computed: "+$z+" (Count: "+$engeCount[0]/4+")"); for ($i = 0; $i < size($nextEdges); ++$i) { global vector $fTargetEdge; global float $angles[]; select $nextEdges[$i]; ConvertSelectionToVertices; string $target[] = `ls -sl -fl`; select -d $vertex; string $nextTarget[] = `ls -sl -fl`; select -tgl $target; string $target[] = `ls -sl -fl`; float $pointRoot[] = `pointPosition $target[0]`; float $pointNext[] = `pointPosition $nextTarget[0]`; vector $one = <<$pointNext[0] - $pointRoot[0],$pointNext[1] - $pointRoot[1],$pointNext[2] - $pointRoot[2]>>; vector $two = <<$fTargetEdge.x - $pointRoot[0],$fTargetEdge.y - $pointRoot[1],$fTargetEdge.z - $pointRoot[2]>>; float $angle = rad_to_deg(angle($one,$two)); $fAngles[size($fAngles)] = $angle; if ($z == $engeCount[0]/4) {select $fSPedges; error "no path!!!";} } global float $fAngles[]; float $angles[] = sort($fAngles); if ($angles[0]>180) error "angle > 180"; int $n = fArrayIndex($angles[0],$fAngles); if ($nextEdges[$n] == $fSPedges[0]) break; $fSPedges[size($fSPedges)] = $nextEdges[$n]; } progressWindow -endProgress; select $fSPedges; fClearUndo; //for free memory } global proc vector fSelCenterVector() { vector $vector; float $floats[] = `xform -q -t`; for ($i = 0; $i >; ++$i; $vector = <<$vector.x,$floats[$i],$vector.z>>; ++$i; $vector = <<$vector.x,$vector.y,$floats[$i]>>; ++$i; if ($i == size($floats)) {return $vector;} } return $vector; } global proc int fArrayIndex(float $float, float $floats[]) { for ($i = 0; $i