// =========================================================================== // 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: 04/21/2016 // // Description: // Performs to add combinatin shape. // // // 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) { if ($forceFactorySettings || !`optionVar -exists seAddCombShpCombMtd`) { optionVar -intValue seAddCombShpCombMtd 1; } } // // Procedure Name: // seAddCombShpOptions // // Description: // Show combination shape option box // // Input Arguments: // Nond. // // Return Value: // None. // global proc seAddCombShpOptions() { // Name of the command for this option box. // string $commandName = "CombinationShape"; // 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. // ================================================= // // Any default option box behaviour based on the command name is set // up with this call. For example, updating the 'Help' menu item with // the name of the command. setOptionBoxCommandName($commandName); // STEP 3: Create option box contents. // ==================================== // setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; string $parent = `columnLayout -adjustableColumn 1`; optionMenuGrp -label (uiRes("m_performAddCombinationShape.kCombineMethod")) -columnAlign 1 "right" seAddCombShpCombMtdGrp; menuItem -l (uiRes("m_performAddCombinationShape.kMultiplication")) "Multiplication"; menuItem -l (uiRes("m_performAddCombinationShape.kLowestWeighting")) "LowestWeighing"; menuItem -l (uiRes("m_performAddCombinationShape.kSmooth")) "Smooth"; setUITemplate -popTemplate; waitCursor -state 0; // STEP 4: Customize the buttons. // =============================== // // Provide more descriptive labels for the buttons. // Disable those buttons that are not applicable to the option box. // Attach actions to those buttons that are applicable to the option box. // 'Apply' button // string $applyBtn = getOptionBoxApplyBtn(); button -e -label (uiRes("m_performAddCombinationShape.kApplyLabel")) -command ($callback + " " + $parent + " 1;") $applyBtn; // 'Reset' button(hidden) string $resetBtn = getOptionBoxResetBtn(); button -e -command($setup + " " + $parent + " 1") $resetBtn; // 'Save' button(hidden) string $saveBtn = getOptionBoxSaveBtn(); button -e -command($callback + " " + $parent + " 0;") $saveBtn; // STEP 5: Set the option box title. // ================================== // setOptionBoxTitle((uiRes("m_performAddCombinationShape.kTitle"))); // STEP 6: Customize the 'Help' menu item text. // TODO: Check with doc team // ============================================= // setOptionBoxHelpTag($commandName); // Set the current values of the option box. // ========================================= // eval ($setup + " " + $parent + " 0"); // Show the option box. // ==================== // showOptionBox(); } // // Procedure Name: // CombinationShapeCallback // // Description: // Callback function for option box // // Input Arguments: // parent - Parent layout // doIt - Whether to execute the commmand // // Return Value: // None. // global proc CombinationShapeCallback(string $parent, int $doIt) { setParent($parent); if(`optionMenuGrp -q -ex seAddCombShpCombMtdGrp`) optionVar -intValue seAddCombShpCombMtd `optionMenuGrp -q -select seAddCombShpCombMtdGrp`; if ($doIt) { string $cmd = "performAddCombinationShape 0"; eval($cmd); addToRecentCommandQueue $cmd "CombinationShape"; } } // // Procedure Name: // CombinationShapeSetup // // Description: // Setup function for option box // // Input Arguments: // parent - Parent layout // forceFactorySettings - Whether reset options // // Return Value: // None. // global proc CombinationShapeSetup(string $parent, int $forceFactorySettings) { setParent($parent); setOptionVars($forceFactorySettings); if(`optionMenuGrp -q -ex seAddCombShpCombMtdGrp`) optionMenuGrp -e -select `optionVar -q seAddCombShpCombMtd` seAddCombShpCombMtdGrp; } // // Procedure Name: // assembleCmd // // Description: // Create execution command // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { int $combineMethod = `optionVar -q seAddCombShpCombMtd` - 1; string $cmd = "doCombinationShapeCreate 0 " + $combineMethod + " 0 \"\""; return $cmd; } // // Procedure Name: // performAddCombinationShape // // Description: // Perform the CombinationShape command using the corresponding // option values. This procedure will also show the option box // window if necessary. // // Input Arguments: // action - 0, Execute the command. // 1, Show the option box dialog. // 2, Return the command. // // Return Value: // None. // global proc string performAddCombinationShape(int $action) { string $cmd = ""; switch ($action) { case 0: // Execute the command // Retrieve the option settings // setOptionVars (false); // Get the command and print it in the command window $cmd = `assembleCmd`; // Execute the command with the option settings evalEcho($cmd); break; case 1: // Do the option box seAddCombShpOptions; break; case 2: // Return the drag string // Retrieve the option settings // setOptionVars (false); // Get the command $cmd = `assembleCmd`; break; } return $cmd; }