// =========================================================================== // 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. // =========================================================================== // // // Description: // Functions called from "Subdiv Tessellate". // // // Procedure Name: // doSubdivCollapseArgList // // Description: // This is the actual function that gets called from "Collapse Hierarchy" // option box. // // Input Arguments: // $version: The version of this option box. This is used to know how to // interpret the $args array. // // history (args[0]) // level (args[1]) // orig object (args[2]) // // Return Value: // None. // // Note: // global proc int doSubdivCollapseArgList( string $version, string $args[] ) { int $status = 0; if( size($args) < 3 ) { string $msg = (uiRes("m_doSubdivCollapseArgList.kWrongNumberOfArgs")); error($msg); return $status; } global int $gSelectSubdivSurface; // collapse all subd's string $list[] = `filterExpand -ex 1 -fp 1 -sm $gSelectSubdivSurface`; int $len = size($list); if ($len == 0) { string $msg = (uiRes("m_doSubdivCollapseArgList.kSelectError")); error ($msg); return $status; } int $origObjectAction = $args[2]; int $globalHist = $args[0]; string $cmd = "subdCollapse"; switch ($origObjectAction) { case 1: // replace original object, forces history off, but delete // will take care of that... $cmd = $cmd + " -ch off "; break; case 2: // hide original object, forces history on $cmd = $cmd + " -ch on "; if( !$globalHist ) { string $msg = (uiRes("m_doSubdivCollapseArgList.kHistoryWarning")); warning($msg); } break; case 3: default: // show original object, respects global construction history $cmd = $cmd + " -ch " + $globalHist + " "; break; } $cmd += (" -level " + $args[1] + " " ); // Convert each subdiv, one at a time so we can catch errors // string $polyRes[]; string $selList = ""; for($i = 0; $i < $len; $i++) { $retVal = catch ($polyRes = evalEcho ($cmd + $list[$i])); // if there's no error, do post work and add results if ($retVal != 1){ switch ($origObjectAction){ case 1: evalEcho ("delete " + $list[$i]); break; case 2: evalEcho ("hide " + $list[$i]); break; default: break; } for ($s in $polyRes) { $selList += ($s + " "); } } } if (size($selList) > 0){ $selList += ";"; eval ("select -r " + $selList); } return $status; }