// =========================================================================== // 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 polyCreateColorSet`) optionVar -stringValue polyCreateColorSet "colorSet"; } global proc performCreateColorSetSetup (string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; string $sval; $sval = `optionVar -query polyCreateColorSet`; textFieldGrp -edit -tx $sval polyCreateColorSet; } global proc performCreateColorSetCallback (string $parent, int $doIt, string $selectCmd) { setParent $parent; optionVar -stringValue polyCreateColorSet `textFieldGrp -query -tx polyCreateColorSet`; if ($doIt) { string $cmd = ("performCreateColorSet \"1\" {\"0\", \"" + $selectCmd + "\", \"0\"} \"\""); eval ($cmd); addToRecentCommandQueue $cmd "createColorSet"; } } proc polyCreateColorSetOptions(string $selectCmd) { string $commandName = "performCreateColorSet"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; string $parent = `columnLayout -adjustableColumn true`; textFieldGrp -label (uiRes("m_performCreateColorSet.kSetName")) polyCreateColorSet; setParent $parent; waitCursor -state 0; setUITemplate -popTemplate; string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCreateColorSet.kCreate")) -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_performCreateColorSet.kOptions")) ); setOptionBoxHelpTag( "CreateEmptyColorSet" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } global proc string performCreateColorSet (string $version, string $args[], string $ColorSetName) // // 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 Color 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="polyColorSet -create -colorSet "; switch ($action) { case 1: polyCreateColorSetOptions $selectCmd; // Just the option box break; case 0: case 2: setOptionVars(false); string $name = `optionVar -query polyCreateColorSet`; if ($forceCreate) $name = $ColorSetName; if (size($name)) { $cmd = ("{string $objects[] = `" + $selectCmd + "`;" + $cmd); $cmd += ("\"" + $name + "\" $objects;}"); if ($action == 0) { evalEcho $cmd; } } else { warning (uiRes("m_performCreateColorSet.kNoName")); } break; } return $cmd; }