// Slide Vertex Tool // // SlideTool; // // Tagincev Vladislav // fiend3d@yandex.ru global int $SlideToolSwapCheck = 0; global string $gSplitNameVert[]; $gSplitNameVert = {""}; global string $g_pntX; $g_pntX = ""; global string $g_pntY; $g_pntY = ""; global string $g_pntZ; $g_pntZ = ""; global string $g_slideRootObj[]; $g_slideRootObj = {""}; global proc SlideTool() { global int $SlideToolSwapCheck; if ($SlideToolSwapCheck==2) {$SlideToolSwapCheck = 0;} if ($SlideToolSwapCheck==0) {SlideToolCreate();} else {SlideToolDelete();} $SlideToolSwapCheck = $SlideToolSwapCheck+1; } global proc SlideToolCreate() { string $searchNode[] = `ls "SlideVertex*" "SlideHelper*" "helpSlideGeom*"`; if (`size $searchNode`!=0) SlideToolClean(); global int $SlideToolSwapCheck; string $slideVertexName[] = `ls -sl -fl `; string $attrsV[] = `listAttr`; float $sX = `getAttr ".pntx"`; float $sY = `getAttr ".pnty"`; float $sZ = `getAttr ".pntz"`; float $queryXYZ[] = `xform -q -ws -t`; ConvertSelectionToFaces; string $slideFaceName[] = `ls -sl -fl `; SelectToggleMode; string $slideRootObj[] = `ls -sl -fl`; string $RootShape[] = `ls -sl -s -dag`; string $slideFaceNameString = stringArrayToString($slideFaceName , " "); string $bufferForSlide[]; tokenize $slideFaceNameString ". " $bufferForSlide; string $removeString[] = {$slideRootObj[0]}; string $bufferForSlide[] = stringArrayRemove($removeString, $bufferForSlide); string $slideFaceNameString = stringArrayToString($bufferForSlide , " "); string $slideFaceNameString = substituteAllString($slideFaceNameString, "f", "helpSlideGeom.f"); tokenize $slideFaceNameString " " $bufferForSlide; duplicate -n "helpSlideGeom"; float $ssX = `getAttr ".sx"`; float $ssY = `getAttr ".sy"`; float $ssZ = `getAttr ".sz"`; HideSelectedObjects; select $bufferForSlide; InvertSelection; doDelete; spaceLocator -n "SlideHelper"; HideSelectedObjects; select "SlideHelper"; move $queryXYZ[0] $queryXYZ[1] $queryXYZ[2]; makeIdentity -apply true -t 1 -r 1 -s 1 -n 0; string $pntX = ($RootShape[0]+"."+$attrsV[1]); string $pntY = ($RootShape[0]+"."+$attrsV[2]); string $pntZ = ($RootShape[0]+"."+$attrsV[3]); string $Exp1 = ($pntX + " = SlideHelper.tx/" + $ssX +" + " + $sX + " ; "); string $Exp2 = ($pntY + " = SlideHelper.ty/" + $ssY +" + " + $sY + " ; "); string $Exp3 = ($pntZ + " = SlideHelper.tz/" + $ssZ +" + " + $sZ + " ; "); expression -s ($Exp1+$Exp2+$Exp3) -n "SlideVertex"; global string $gSplitNameVert[]; $gSplitNameVert = $slideVertexName; global string $g_pntX; global string $g_pntY; global string $g_pntZ; $g_pntX=$pntX; $g_pntY=$pntY; $g_pntZ=$pntZ; global string $g_slideRootObj[]; $g_slideRootObj = $slideRootObj; select "helpSlideGeom"; select -add "SlideHelper"; geometryConstraint -weight 1; select "SlideHelper"; hilite -r $slideRootObj[0] ; } global proc SlideToolDelete() { global int $SlideToolSwapCheck; global string $gSplitNameVert[]; global string $g_pntX; global string $g_pntY; global string $g_pntZ; global string $g_slideRootObj[]; select $gSplitNameVert; float $sX = `getAttr ".pntx"`; float $sY = `getAttr ".pnty"`; float $sZ = `getAttr ".pntz"`; delete SlideVertex; setAttr $g_pntX $sX; setAttr $g_pntY $sY; setAttr $g_pntZ $sZ; select -r helpSlideGeom SlideHelper ; doDelete; SelectVertexMask; select $gSplitNameVert; hilite -r $g_slideRootObj[0] ; } global proc SlideToolClean() { string $searchNode[] = `ls "SlideVertex*" "SlideHelper*" "helpSlideGeom*"`; delete $searchNode; }