// =========================================================================== // 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: // doSubdivTessArgList // // Description: // This is the actual function that gets called from "Subdiv Tessellate" // option box. // // Input Arguments: // $version: The version of this option box. This is used to know how to // interpret the $args array. // // Return Value: // None. // // Note: // global proc int doSubdivTessArgList( string $version, string $args[] ) { int $status = 0; if( size($args) < 7 ) { error (uiRes("m_doSubdivTessArgList.kTooFewArgsVer1")); return $status; } if( ("2" == $version) && (size($args) < 8) ) { error (uiRes("m_doSubdivTessArgList.kTooFewArgsVer2")); return $status; } if( ("3" == $version) && (size($args) < 9) ) { error (uiRes("m_doSubdivTessArgList.kTooFewArgsVer3")); return $status; } string $whatWithPoints; string $shareUVs = "0"; if( "1" == $version ) { $whatWithPoints = "0"; } else { $whatWithPoints = $args[7]; if( "3" == $version ) { $shareUVs = $args[8]; } } global int $gSelectSubdivSurface; // tessellate all subd's string $list[] = `filterExpand -ex 1 -fp 1 -sm $gSelectSubdivSurface`; int $len = size($list); if ($len == 0) { error (uiRes("m_doSubdivTessArgList.kInvalidSelection")); return $status; } int $origObjectAction = $args[5]; int $globalHist = $args[0]; string $cmd = "subdToPoly"; switch ($origObjectAction) { case 1: // replace original object, forces history off, but delete // will take care of that... $cmd = $cmd + " -ch off -aut on"; break; case 2: // hide original object, forces history on $cmd = $cmd + " -ch on -aut on"; if( !$globalHist ) { warning (uiRes("m_doSubdivTessArgList.kForceConstructionHist")); } break; case 3: default: // show original object, respects global construction history $cmd = $cmd + " -ch " + $globalHist + " -aut on"; break; } $cmd += (" -format " + $args[1]); $cmd += (" -depth " + $args[2]); $cmd += (" -sampleCount " + $args[3]); $cmd += (" -maxPolys " + $args[4]); $cmd += (" -extractPointPosition " + $whatWithPoints); $cmd += (" -shareUVs " + $shareUVs); $cmd += (" -subdNormals " + $args[6] + " " ); // Convert each subdiv, one at a time so we can catch errors // string $polyRes[]; string $selList = ""; for($i = 0; $i < $len; $i++) { int $vis = `getAttr ($list[$i] + ".visibility")`; if (!$vis) continue; $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]); // evalEcho ("setAttr " + $list[$i] + ".io " + 1); break; default: break; } for ($s in $polyRes) { $selList += ($s + " "); } } } if (size($selList) > 0){ $selList += ";"; eval ("select -r " + $selList); // Initialize the new mesh with the global settings. setupNewMesh(); } return $status; }