// =========================================================================== // 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. // =========================================================================== proc setOptionVars (int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists polyCopyUVSet`) optionVar -stringValue polyCopyUVSet "uvSet"; } global proc performCopyCurrentUVSetSetup (string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; string $sval; $sval = `optionVar -query polyCopyUVSet`; textFieldGrp -edit -tx $sval polyCopyUVSet; } global proc performCopyCurrentUVSetCallback (string $parent, int $doIt, string $selectCmd) { setParent $parent; optionVar -stringValue polyCopyUVSet `textFieldGrp -query -tx polyCopyUVSet`; if ($doIt) { string $cmd = ("performCopyCurrentUVSet \"1\" {\"0\", \"" + $selectCmd + "\", \"0\"} \"\""); eval ($cmd); addToRecentCommandQueue $cmd "copyCurrentUVSet"; } } proc polyCopyCurrentUVSetOptions(string $selectCmd) { // Global template variables for form spacing global int $gOptionBoxTemplateFrameSpacing; string $commandName = "performCopyCurrentUVSet"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate OptionBoxTemplate; waitCursor -state 1; // Form layout string $parent = `formLayout polyCopyUVSetOptions`; // Settings frame string $settingsFrame = `frameLayout -label (uiRes("m_performCopyCurrentUVSet.kSettingsFrame"))`; textFieldGrp -label (uiRes("m_performCopyCurrentUVSet.kUVSetName")) polyCopyUVSet; setParent $parent; setParent ..; // Attach frame to form layout formLayout -e -af $settingsFrame "top" $gOptionBoxTemplateFrameSpacing -af $settingsFrame "left" $gOptionBoxTemplateFrameSpacing -af $settingsFrame "right" $gOptionBoxTemplateFrameSpacing -an $settingsFrame "bottom" $parent; waitCursor -state 0; setUITemplate -popTemplate; string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCopyCurrentUVSet.kApplyButton")) -command ($callback + " " + $parent + " " + 1 + " \"" + $selectCmd + "\"") $applyBtn; string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + " \"" + $selectCmd + "\"" + "; hideOptionBox") $saveBtn; string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; setOptionBoxTitle( (uiRes("m_performCopyCurrentUVSet.kCopyOptions")) ); setOptionBoxHelpTag( "CopyCurrentUVSet" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } global proc string performCopyCurrentUVSet (string $version, string $args[], string $uvSetName) // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $action, $selectCmd // // $args // Version 1 // [0] $action 0 : Execute the command. // 1 : Show the option box dialog. // 2 : Return the command. // [1] $selectCmd The command to issue to determine which objects // to affect // [2] $forceCreate Whether or not to force creation of a new UV set // // Return Value: // The string to execute for this option box. // { int $versionNum = $version; int $action = $args[0]; string $selectCmd = $args[1]; int $forceCreate = $args[2]; string $cmd; switch ($action) { case 1: polyCopyCurrentUVSetOptions $selectCmd; // Just the option box break; case 0: case 2: setOptionVars(false); string $name = `optionVar -query polyCopyUVSet`; $cmd = "{string $name = `optionVar -query polyCopyUVSet`; "; $selList = eval($selectCmd); if (size($selList)) { string $selObj[]; if (endsWith($selList[0], "]")) { $selObj = `listRelatives -parent $selList[0]`; } else $selObj = `listRelatives -fullPath $selList[0]`; if (size($selObj)) { string $uniqueNames[] = `polyUVSet -q -gen -uvSet $name $selObj[0]`; if (size($uniqueNames)) $name = $uniqueNames[0]; } } $cmd += "$selList = eval($selectCmd); " + "if (size($selList)) { " + " string $selObj[]; " + " if (endsWith($selList[0], \"]\")) " + " { " + " $selObj = `listRelatives -parent $selList[0]`; " + " } " + " else " + " $selObj = `listRelatives -fullPath $selList[0]`;" + " if (size($selObj)) {" + " string $uniqueNames[] = `polyUVSet -q -gen -uvSet $name $selObj[0]`;" + " if (size($uniqueNames))" + " $name = $uniqueNames[0];" + " }" + "} "; if ($forceCreate) $name = $uvSetName; if (size($name)) { string $curUVSet[] = `polyUVSet -q -currentUVSet`; $cmd += "string $curUVSet[] = `polyUVSet -q -currentUVSet`; "; if ($action == 0) { performPolyCopyUVsToUVsetArgList "1" {$curUVSet[0], $name, "1"}; $cmd += ("performPolyCopyUVsToUVsetArgList \"1\" {\"" + $curUVSet[0] + "\", \"" + $name + "\", \"1\"};}"); } } else if ($action == 0) { warning (uiRes("m_performCopyCurrentUVSet.kNoName")); } break; } return $cmd; }