// =========================================================================== // 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 to NURBS conversion". // // // Procedure Name: // doSubdivToNurbs // // Description: // This is the actual function that gets called from "Subdiv to NURBS" // option box. // // Input Arguments: // None. // // Return Value: // None. // // Note: // global proc int doSubdivToNurbs( string $args[] ) { int $status = 0; if( size($args) < 1 ) { error (uiRes("m_doSubdivToNurbs.kTooFewArgs")); return $status; } global int $gSelectSubdivSurface; // convert all subd's string $list[] = `filterExpand -ex 1 -fp 1 -sm $gSelectSubdivSurface`; int $len = size($list); if ($len == 0) { error (uiRes("m_doSubdivToNurbs.kInvalidSelection")); return $status; } int $globalHist = $args[0]; int $origObjectAction = $args[1]; int $outputType = $args[2]; string $cmd = "subdToNurbs"; 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_doSubdivToNurbs.kForceConstructionHist")); } break; case 3: default: // show original object, respects global construction history $cmd = $cmd + " -ch " + $globalHist + " -aut on"; break; } // output type $cmd = $cmd + " -ot " + $outputType + " "; // Convert each subdiv, one at a time so we can catch errors // string $nurbsRes[]; string $selList = ""; for($i = 0; $i < $len; $i++) { int $vis = `getAttr ($list[$i] + ".visibility")`; if (!$vis) continue; $retVal = catch ($nurbsRes = 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 $nurbsRes) { $selList += ($s + " "); } } } if (size($selList) > 0){ $selList += ";"; eval ("select -r " + $selList); } return $status; }