// =========================================================================== // 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. // =========================================================================== // // // Creation Date: June 5, 1997 // // Description: // This is a helper script to perfrom the delete -staticChannels command // using the various options that have been set // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { // -hierarchy // if ($forceFactorySettings || !`optionVar -exists deleteStaticChannelsHierarchy`) { optionVar -stringValue deleteStaticChannelsHierarchy "none"; } // -controlPoints // if ($forceFactorySettings || !`optionVar -exists deleteStaticChannelsControlPoints`) { optionVar -intValue deleteStaticChannelsControlPoints 0; } // -shape // if ($forceFactorySettings || !`optionVar -exists deleteStaticChannelsShapes`) { optionVar -intValue deleteStaticChannelsShapes 1; } // use channel box attrs // if ($forceFactorySettings || !`optionVar -exists deleteStaticChannelsUseChannelBox`) { optionVar -intValue deleteStaticChannelsUseChannelBox 0; } // delete driven (unitless) animCurves // if ($forceFactorySettings || !`optionVar -exists deleteStaticChannelsDriven`) { optionVar -intValue deleteStaticChannelsDriven 0; } } // // Procedure Name: // deleteStaticChannelsSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc deleteStaticChannelsSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); setParent $parent; // -hierarchy // string $hierarchy = `optionVar -query deleteStaticChannelsHierarchy`; if ($hierarchy == "below") { radioButtonGrp -edit -select 2 hierarchy; } else { radioButtonGrp -edit -select 1 hierarchy; } // use set driven attrs // int $drivenAttrs = `optionVar -q deleteStaticChannelsDriven`; checkBoxGrp -e -value1 $drivenAttrs driven; // -controlPoints // int $controlPoints = `optionVar -q deleteStaticChannelsControlPoints`; checkBoxGrp -e -value1 $controlPoints controlPoints; // -shape // int $shapes = `optionVar -q deleteStaticChannelsShapes`; checkBoxGrp -e -value1 $shapes shapes; // use channel box attrs // int $boxAttrs = `optionVar -q deleteStaticChannelsUseChannelBox`; radioButtonGrp -e -select ( $boxAttrs + 1 ) channels; // Now get all the dependent widgets in the right // enabled/disabled/collapsed/expanded state // deleteStaticChannelsWidgetsEnable; } // // Procedure Name: // deleteStaticChannelsCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // Return Value: // None. // global proc deleteStaticChannelsCallback(string $parent, int $doIt) { setParent $parent; // -hierarchy // string $hierarchy; int $selected = `radioButtonGrp -query -select hierarchy`; if ($selected == 2) { $hierarchy = "below"; } else { $hierarchy = "none"; } optionVar -stringValue deleteStaticChannelsHierarchy $hierarchy; // -controlPoints // int $controlPoints = `checkBoxGrp -query -value1 controlPoints`; optionVar -intValue deleteStaticChannelsControlPoints $controlPoints; // -shapes // int $shapes = `checkBoxGrp -query -value1 shapes`; optionVar -intValue deleteStaticChannelsShapes $shapes; // use driven attrs // int $drivenAttrs = `checkBoxGrp -query -value1 driven`; optionVar -intValue deleteStaticChannelsDriven $drivenAttrs; // use channel box attrs // int $boxAttrs = `radioButtonGrp -query -select channels`; optionVar -intValue deleteStaticChannelsUseChannelBox ($boxAttrs - 1); if( $doIt ) { performDeleteStaticChannels 0; addToRecentCommandQueue "performDeleteStaticChannels 0" "DeleteStaticChannels"; } } global proc deleteStaticChannelsWidgetsEnable() // // Description: // These are the widgets that get enabled and // disabled based on the certain states. Put them // here so they're all in one place. // { // Control points and shapes // $enableIt = (( `radioButtonGrp -q -select channels` == 1 ) && ( `radioButtonGrp -q -enable channels` ) && ! `frameLayout -q -collapse hierChanAttrFrame` ); frameLayout -e -enable $enableIt attributesFrame; } // // Procedure Name: // deleteStaticChannelsOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc deleteStaticChannelsOptions() { // Name of the command for this option box. // string $commandName = "deleteStaticChannels"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: Get the option box. // ============================ // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; // STEP 2: Pass the command name to the option box - see STEP 8. // ============================================================== // STEP 3: Activate the default UI template. // ========================================== // // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; frameLayout -bv no -lv no -collapsable no hierChanAttrFrame; string $below = (uiRes("m_performDeleteStaticChannels.kBelow")); columnLayout -adjustableColumn true; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performDeleteStaticChannels.kHierarchy")) -label1 (uiRes("m_performDeleteStaticChannels.kSelected")) -label2 $below hierarchy; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performDeleteStaticChannels.kChannels")) -label1 (uiRes("m_performDeleteStaticChannels.kAllKeyable")) -cc1 "deleteStaticChannelsWidgetsEnable" -label2 (uiRes("m_performDeleteStaticChannels.kFromChannelBox")) -cc2 "deleteStaticChannelsWidgetsEnable" channels; frameLayout -bv no -lv no -collapsable no attributesFrame; columnLayout -adjustableColumn true; checkBoxGrp -value1 0 -ncb 1 -label (uiRes("m_performDeleteStaticChannels.kDrivenChannels")) -label1 "" driven; checkBoxGrp -label (uiRes("m_performDeleteStaticChannels.kControlPoints")) -ncb 1 -value1 off -label1 "" controlPoints; checkBoxGrp -label (uiRes("m_performDeleteStaticChannels.kShapes")) -ncb 1 -value1 on -label1 "" shapes; setParent ..; setParent ..; setParent ..; setParent ..; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // Provide more descriptive labels for the buttons. This is not // necessary, but in some cases, for example, a button labelled // 'Create' may be more meaningful to the user than one labelled // 'Apply'. // // Disable those buttons that are not applicable to the option box. // // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performDeleteStaticChannels.kDelete")) -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performDeleteStaticChannels.kDeleteStaticChannelsOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "DeletebyTypeStaticChannels" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // deleteStaticChannelsHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string deleteStaticChannelsHelp() { // ******** Example // " Command: Extrude - create a surface using extrusion.\n" + // "Selection: curves and isoparms." return " Command: deleteStaticChannels"; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = "delete -staticChannels "; int $useChannelBox = `optionVar -query deleteStaticChannelsUseChannelBox`; string $hierarchy = `optionVar -query deleteStaticChannelsHierarchy`; if( !`optionVar -query deleteStaticChannelsDriven` ) { $cmd += "-unitlessAnimationCurves false"; } if( $useChannelBox == 1 ) { string $syntax[] = keySetOptionBoxCommon( { "deleteStaticChannels", "unknown", "channelBoxSyntax" } ); if( size( $syntax[0] ) == 0 ) { $cmd = ""; warning (uiRes("m_performDeleteStaticChannels.kNoChannelsWarn")); } else { $cmd = ( $cmd + "-hierarchy " + $hierarchy + " " ); $cmd = $cmd + $syntax[0]; } } else { $cmd = ( $cmd + " -hierarchy " + $hierarchy + " -controlPoints " + `optionVar -query deleteStaticChannelsControlPoints` + " -shape " + `optionVar -query deleteStaticChannelsShapes` ); } return $cmd; } // // Procedure Name: // performDeleteStaticChannels // // Description: // Perform the deleteStaticChannels command using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the deleteStaticChannels command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performDeleteStaticChannels(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // evalEcho($cmd); break; // Show the option box. // case 1: deleteStaticChannelsOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }