// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Procedure Name: // performPolyNudgeUVs // // Description: // // // Input Arguments: // $dir : The nudge direction. Valid values are "upLeft", "up", // "upRight", "left", "right", "downLeft", "down", "downRight" // // // Initialize optionVars for performPolyNudgeUVs: // proc setOptionVars (int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists polyNudgeUVFactor`) optionVar -floatValue polyNudgeUVFactor 0.1; if ($forceFactorySettings || !`optionVar -exists polyNudgeUVAbsolute`) optionVar -intValue polyNudgeUVAbsolute 0; // Default to relative } global proc performPolyNudgeUVs( string $dir ) { setOptionVars(false); float $nudgeFactor = `optionVar -q polyNudgeUVFactor`; int $nudgeUVAbsolute = `optionVar -q polyNudgeUVAbsolute`; float $uValue = 0.0; float $vValue = 0.0; // Relative nudge if( $dir == "upLeft" || $dir == "left" || $dir == "downLeft" ) { $uValue = $nudgeFactor * -1.0; } else if ( $dir == "upRight" || $dir == "right" || $dir == "downRight" ) { $uValue = $nudgeFactor; } if( $dir == "upLeft" || $dir == "up" || $dir == "upRight" ) { $vValue = $nudgeFactor; } else if ( $dir == "downLeft" || $dir == "down" || $dir == "downRight" ) { $vValue = $nudgeFactor * -1.0; } // Absolute nudge if ( $nudgeUVAbsolute ) { float $bbox[] = `polyEvaluate -boundingBoxComponent2d`; float $centerU = ($bbox[1] + $bbox[0]) * 0.5; float $centerV = ($bbox[3] + $bbox[2]) * 0.5; $uValue = $nudgeFactor - $centerU; $vValue = $nudgeFactor - $centerV; if( $dir == "up" || $dir == "down" ) $uValue = 0.0; else if( $dir == "left" || $dir == "right" ) $vValue = 0.0; } // to move the manip string $selectObj[] = `ls -dag -objectsOnly -selection`; for ( $obj in $selectObj ) { float $uvPivot[] = `getAttr ($obj+".uvPivot")`; if ( $dir == "upLeft" || $dir == "left" || $dir == "downLeft" || $dir == "upRight" || $dir == "right" || $dir == "downRight" ) { $uvPivot[0] += $uValue; } if ( $dir == "upLeft" || $dir == "up" || $dir == "upRight" || $dir == "downLeft" || $dir == "down" || $dir == "downRight" ) { $uvPivot[1] += $vValue; } string $setAttrCmd = ("setAttr " + $obj+".uvPivot -type double2 " + $uvPivot[0] + " " + $uvPivot[1]); evalEcho ($setAttrCmd); } // to move the UVs string $cmd = ("polyEditUV -u " + $uValue + " -v " + $vValue); evalEcho ($cmd); }