// =========================================================================== // 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. // =========================================================================== global proc truncateUV(int $precision) { string $selectedItems[]; $selectedItems = `filterExpand -ex true -sm 35`; if (size($selectedItems) == 0) return; float $uv[2], $olduv[2]; int $pre = `abs $precision`; float $fmultip = `pow 10 $pre`; float $round = 0.5; string $uvStr; int $i=0; while (size($selectedItems) > $i) { $uvStr = $selectedItems[$i]; $cmd = ("polyEditUV -q -u -v " + $uvStr + ";"); $uv = `eval $cmd`; $olduv = $uv; // Truncate 10^precision bits $uv[0] = ( (int) (($uv[0] * $fmultip) + $round) / $fmultip ); $uv[1] = ( (int) (($uv[1] * $fmultip) + $round) / $fmultip ); //print ("old uv = " + $olduv[0] + " " + $olduv[1] + "\n"); //print ("new uv = " + $uv[0] + " " + $uv[1] + "\n"); polyEditUV -r off -u $uv[0] -v $uv[1] $uvStr; $i++; } }