// =========================================================================== // 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 polyCreateUVSet`) optionVar -stringValue polyCreateUVSet "uvSet"; if ($forceFactorySettings || !`optionVar -exists perInstanceUVSet`) optionVar -intValue perInstanceUVSet 0; } global proc performCreateUVSetSetup (string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; string $sval; $sval = `optionVar -query polyCreateUVSet`; textFieldGrp -edit -tx $sval polyCreateUVSet; int $perInstVal = `optionVar -query perInstanceUVSet`; radioButtonGrp -edit -select ($perInstVal+1) perInstanceUVRadio; } global proc performCreateUVSetCallback (string $parent, int $doIt, string $selectCmd) { setParent $parent; optionVar -stringValue polyCreateUVSet `textFieldGrp -query -tx polyCreateUVSet`; int $perInstanceRadio = `radioButtonGrp -q -sl perInstanceUVRadio`; int $perInstance = ($perInstanceRadio-1); optionVar -intValue perInstanceUVSet $perInstance; if ($doIt) { string $cmd = ("performCreateUVSet \"2\" {\"0\", \"" + $selectCmd + "\", \"0\", \""+$perInstance+"\"} \"\""); eval ($cmd); addToRecentCommandQueue $cmd "createUVSet"; } } proc polyCreateUVSetOptions(string $selectCmd) { // Global template variables for form spacing global int $gOptionBoxTemplateFrameSpacing; string $commandName = "performCreateUVSet"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate OptionBoxTemplate; waitCursor -state 1; string $parent = `columnLayout -adjustableColumn 1`; // Form layout $parent = `formLayout polyCreateUVSetOptions`; setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; textFieldGrp -label (uiRes("m_performCreateUVSet.kCreateUVSetName")) polyCreateUVSet; radioButtonGrp -numberOfRadioButtons 3 -vr -label (uiRes("m_performCreateUVSet.kUvSetSharing")) -label1 (uiRes("m_performCreateUVSet.kShared")) -label2 (uiRes("m_performCreateUVSet.kPerInstanceShared")) -label3 (uiRes("m_performCreateUVSet.kPerInstanceUnshared")) perInstanceUVRadio; waitCursor -state 0; setUITemplate -popTemplate; string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCreateUVSet.kCreateButton")) -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_performCreateUVSet.kCreateOptions")) ); setOptionBoxHelpTag( "CreateEmptyUVSet" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } global proc string performCreateUVSet (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 // Version 2 // [3] $perInstance 0=shared, 1=per-instance shared, 2=per-instance unshared // // 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]; int $perInstance = 0; if ($versionNum > 1) { $perInstance = $args[3]; } string $cmd="polyUVSet -create "; if ($perInstance > 0) { $cmd += ("-perInstance true "); if ($perInstance == 2) { $cmd += ("-unshared "); } } $cmd += "-uvSet "; switch ($action) { case 1: polyCreateUVSetOptions $selectCmd; // Just the option box break; case 0: case 2: setOptionVars(false); string $name = `optionVar -query polyCreateUVSet`; if ($forceCreate) $name = $uvSetName; if (size($name)) { $cmd = ("{string $objects[] = `" + $selectCmd + "`;" + $cmd); $cmd += ("\"" + $name + "\" $objects;}"); if ($action == 0) { evalEcho $cmd; } } else { warning (uiRes("m_performCreateUVSet.kNoNameSpecified")); } break; } return $cmd; }