// =========================================================================== // 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. // =========================================================================== // // // Creation Date: Mar. 14, 1997 // // Description: // The reversePreset() procedure executes a reverse operation on each // selected object based on the reverse option vars. // // Input Arguments: // None. // // Return Value: // None. // global proc reversePreset( int $doHistory, int $replaceOriginal, int $reverseSurfaceDirection ) { // Get a list of each type of acceptable object type - surfaces, // curves, and curves-on-surface. // global int $gSelectNurbsSurfacesBit; global int $gSelectNurbsCurvesBit; global int $gSelectCurvesOnSurfacesBit; global int $gSelectIsoparmsBit; string $surfaceList[] = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit`; string $isoparmList[] = `filterExpand -ex true -sm $gSelectIsoparmsBit`; string $curveList[] = `filterExpand -ex true -sm $gSelectNurbsCurvesBit`; string $COSList[] = `filterExpand -ex true -sm $gSelectCurvesOnSurfacesBit`; // Set up command strings for each command and execute them: // reverseSurface and reverseCurve and reverseCurve for curves-on-surface. // string $cmd; $cmd = "reverseSurface -d " + $reverseSurfaceDirection + " -ch " + $doHistory + " -rpo " + $replaceOriginal + " %s;"; string $surfaceResults[] = executeForEachObject( $surfaceList, $cmd ); $cmd = "reverseCurve" + " -ch " + $doHistory + " -rpo " + $replaceOriginal + " %s;"; string $curveResults[] = executeForEachObject( $curveList, $cmd ); $cmd = "reverseCurve " + " -ch " + $doHistory + " -rpo " + $replaceOriginal + " -cos on %s;"; string $cosResults[] = executeForEachObject( $COSList, $cmd ); // Processing isoparms is a little more involved. Use groupObjectsByName(). // $cmd = "reverseSurface " + " -ch " + $doHistory + " -rpo " + $replaceOriginal + " "; string $isoparmResults[]; string $isoparms[] = groupObjectsByName( $isoparmList, "\\." ); int $numIsoStrs = size($isoparms); for( $i = 0; $i < $numIsoStrs; $i ++ ) { string $reverseCmd; string $results[]; string $objectName[]; $numNames = `tokenize $isoparms[$i] " " $objectName`; if( $numNames == 1 ) { $reverseCmd = $cmd + $isoparms[$i]; } else { string $foundU = `match "\\.u\\[" $isoparms[$i]`; string $foundV = `match "\\.v\\[" $isoparms[$i]`; if( size($foundU)> 0 && size($foundV) > 0 ) { tokenize $isoparms[$i] "\\." $objectName; $reverseCmd = $cmd + "-d 2 " + $objectName[0]; } else { tokenize $isoparms[$i] " " $objectName; $reverseCmd = $cmd + $isoparms[$i]; } } if( catch( $results = evalEcho( $reverseCmd )) ) { string $fmt = (uiRes("m_reversePreset.kReverseSurfaceDirInvalidCmd")); error `format -s $reverseCmd $fmt`; } else { int $j; int $numResults = size( $results ); int $numIsoResults = size( $isoparmResults ); for( $j = 0; $j < $numResults; $j ++, $numIsoResults ++ ) { $isoparmResults[$numIsoResults] = $results[$j]; } } } if( (size($surfaceResults)+size($curveResults)+ size($cosResults)+size($isoparmResults)) == 0 ) { error (uiRes("m_reversePreset.kReverseSurfaceDirInvalSelection")); } else { // Select all the results with one select command. Note that only // resulting surfaces and curves are selected, not dependency nodes. // string $selectString; $selectString = "select "; int $i; int $numSurfaces = size($surfaceResults); for( $i = 0; $i < $numSurfaces; $i ++ ) { $selectString += $surfaceResults[$i]; $selectString += " "; } int $numIsoparms = size($isoparmResults); for( $i = 0; $i < $numIsoparms; $i ++ ) { $selectString += $isoparmResults[$i]; $selectString += " "; } int $numCurves = size($curveResults); for( $i = 0; $i < $numCurves; $i ++ ) { $selectString += $curveResults[$i]; $selectString += " "; } int $numCOS = size($cosResults); for( $i = 0; $i < $numCOS; $i ++ ) { $selectString += $cosResults[$i]; $selectString += " "; } $selectString += ";"; select -cl; eval($selectString); } }