// =========================================================================== // 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, 1999 // // Description: // The doExtendSurfaceArgList() procedure executes a extend operation on // each selected object based on the extend option vars. // // Input Arguments: // None. // // Versions: // 1 - Maya V2 proc string prepareExtendSurface( string $version, string $args[], int $forSurface ) { string $cmd = ""; int $need = 0; if( "1" == $version ) { $need = 8; } else { warning (uiRes("m_doExtendSurfaceArgList.kBadVersion")); $version = "1"; $need = 8; } if( size($args) < $need ) { error (uiRes("m_doExtendSurfaceArgList.kTooFewArgs")); return $cmd; } // Set up command strings for each command. $cmd = "extendSurface"; $cmd = $cmd + " -ch " + $args[0]; $cmd = $cmd + " -em " + $args[1]; $cmd = $cmd + " -et " + $args[2]; $cmd = $cmd + " -d " + $args[3]; $cmd = $cmd + " -jn " + $args[5]; // If join is not set, force keep originals (rpo off) string $rpo = $args[6]; int $join = $args[5]; if( !$join ) { $rpo = "off"; } $cmd = $cmd + " -rpo " + $rpo; if( $forSurface ) { $cmd = $cmd + " -es " + $args[4]; $cmd = $cmd + " -ed " + $args[7]; } $cmd = $cmd + " "; return $cmd; } global proc doExtendSurfaceArgList( string $version, string $args[] ) { string $cmd = prepareExtendSurface( $version, $args, 1 ); if( "" == $cmd ) return; // Get a list of each type of acceptable object type - surfaces+iso. // global int $gSelectNurbsSurfacesBit; global int $gSelectIsoparmsBit; string $surfaceList[] =`filterExpand -ex true -sm $gSelectNurbsSurfacesBit`; string $isoList[] = `filterExpand -ex true -sm $gSelectIsoparmsBit`; $cmd += " %s;"; string $surfaceResults[] = executeForEachObject( $surfaceList, $cmd ); // Processing isoparms is a little more involved. Use groupObjectsByName(). // This big loop groups and processes >1 isoparms and sets the // direction of the command based on the isoparm direction. // Also, if the user selects an isoparm in each direction on the same // surface, this code assumes that the user wants to extend the // surface in BOTH directions. // $cmd = prepareExtendSurface( $version, $args, 0 ); string $isoparmResults[]; string $isoparms[] = groupObjectsByName( $isoList, "\\." ); int $numIsoStrs = size($isoparms); for( $i = 0; $i < $numIsoStrs; $i ++ ) { string $extendCmd; string $results[]; string $objectName[]; $numNames = `tokenize $isoparms[$i] "\\." $objectName`; if( $numNames == 1 ) { $extendCmd = $cmd + $isoparms[$i]; } else { string $foundU = `match "\\.u\\[" $isoparms[$i]`; string $foundV = `match "\\.v\\[" $isoparms[$i]`; if( size($foundU) > 0 && size($foundV) > 0 ) { $extendCmd = $cmd + "-ed 2 " + $objectName[0]; } else if( size($foundU) > 0 ) { $extendCmd = $cmd + "-ed 0 " + $objectName[0]; } else if( size($foundV) > 0 ) { $extendCmd = $cmd + "-ed 1 " + $objectName[0]; } } if( catch( $results = evalEcho( $extendCmd )) ) { string $fmt = (uiRes("m_doExtendSurfaceArgList.kProblemExecutingCmd")); error `format -s $extendCmd $fmt`; } else { int $j; int $numResults = size( $results ); int $numIsoResults = size( $isoparmResults ); for( $j = 0; $j < $numResults; $j ++, $numIsoResults ++ ) { $isoparmResults[$numIsoResults] = $results[$j]; } } } // Process all the results - if there weren't any then display a error // if( 0 == (size($surfaceResults) + size($isoparmResults)) ) { if( 0 == (size($surfaceList) + size($isoList)) ) { error (uiRes("m_doExtendSurfaceArgList.kInvalidSelection")); } else { warning (uiRes("m_doExtendSurfaceArgList.kProducedNoResults")); } } 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 $numIsos = size($isoparmResults); for( $i = 0; $i < $numIsos; $i ++ ) { $selectString += $isoparmResults[$i]; $selectString += " "; } $selectString += ";"; select -cl; eval($selectString); } }