// =========================================================================== // 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: August, 2002 // // Description: // This script provides an option box dialog for // restricting the constrained axes. // // Input Arguments: // boolean showOptionBox true - show the option box dialog // false - just execute the command // // 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 restrictConstraintX`) { optionVar -intValue restrictConstraintX 1; } if ($forceFactorySettings || !`optionVar -exists restrictConstraintY`) { optionVar -intValue restrictConstraintY 1; } if ($forceFactorySettings || !`optionVar -exists restrictConstraintZ`) { optionVar -intValue restrictConstraintZ 1; } // maintain existing offset // if ($forceFactorySettings || !`optionVar -exists restrictAxisMaintainOffset`) { optionVar -intValue restrictAxisMaintainOffset 0; } } // // Procedure Name: // restrictAxesSetup // // 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 restrictAxesSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; checkBoxGrp -edit -value1 `optionVar -query restrictConstraintX` restrictXWidget; checkBoxGrp -edit -value1 `optionVar -query restrictConstraintY` restrictYWidget; checkBoxGrp -edit -value1 `optionVar -query restrictConstraintZ` restrictZWidget; checkBoxGrp -edit -value1 `optionVar -query restrictAxisMaintainOffset` restrictAxisMaintainWidget; } // // Procedure Name: // restrictAxesCallback // // 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 restrictAxesCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. optionVar -intValue restrictConstraintX `checkBoxGrp -query -value1 restrictXWidget`; optionVar -intValue restrictConstraintY `checkBoxGrp -query -value1 restrictYWidget`; optionVar -intValue restrictConstraintZ `checkBoxGrp -query -value1 restrictZWidget`; // maintain offset // optionVar -intValue restrictAxisMaintainOffset `checkBoxGrp -query -value1 restrictAxisMaintainWidget`; if ($doIt) { performModifyConstraintAxes 0; addToRecentCommandQueue "performModifyConstraintAxes 0" "ModifyConstraintAxes"; } } // // Procedure Name: // restrictAxesOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc restrictAxesOptions() { // Name of the command for this option box. // string $commandName = "restrictAxes"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Get the option box. // string $layout = getOptionBox(); setParent $layout; // Pass the command name to the option box. // setOptionBoxCommandName($commandName); // Activate the default UI template. // setUITemplate -pushTemplate DefaultTemplate; // Turn on the wait cursor. // waitCursor -state 1; tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; checkBoxGrp -label (uiRes("m_performModifyConstraintAxes.kConstrain")) -label1 (uiRes("m_performModifyConstraintAxes.kX")) -annotation (uiRes("m_performModifyConstraintAxes.kXConstraintAnnot")) -numberOfCheckBoxes 1 restrictXWidget; checkBoxGrp -label "" -label1 (uiRes("m_performModifyConstraintAxes.kY")) -annotation (uiRes("m_performModifyConstraintAxes.kYConstraintAnnot")) -numberOfCheckBoxes 1 restrictYWidget; checkBoxGrp -label1 (uiRes("m_performModifyConstraintAxes.kZ")) -annotation (uiRes("m_performModifyConstraintAxes.kZConstraintAnnot")) -numberOfCheckBoxes 1 restrictZWidget; checkBoxGrp -label (uiRes("m_performModifyConstraintAxes.kMaintainOffset")) -label1 " " -annotation (uiRes("m_performModifyConstraintAxes.kMaintainOffsetAnnot")) -numberOfCheckBoxes 1 restrictAxisMaintainWidget; // Turn off the wait cursor. // waitCursor -state 0; // Deactivate the default UI template. // setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performModifyConstraintAxes.kModifyButton")) -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; // Set the option box title. // setOptionBoxTitle (uiRes("m_performModifyConstraintAxes.kModifyConstrainedAxisOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "ModifyConstrainedAxis" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } // // Procedure Name: // restrictAxesHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string restrictAxesHelp() { return (" Command: Modify Constrained Axes - restrict axes a constraint.\n" + "Selection: "); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { string $cmd = "doModifyConstraintAxes 1 "; setOptionVars(false); int $maintainOffset = `optionVar -q restrictAxisMaintainOffset`; int $cx = `optionVar -q restrictConstraintX`; int $cy = `optionVar -q restrictConstraintY`; int $cz = `optionVar -q restrictConstraintZ`; $cmd = ($cmd + " { " + "\""+ $cx + "\"" + ",\""+ $cy + "\"" + ",\""+ $cz + "\"" + ",\""+ $maintainOffset + "\"" + "};"); return $cmd; } // // Procedure Name: // performModifyConstraintAxes // // Description: // Perform the constraint command using the corresponding // option values related to restricting the constraint axis. // This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the restrictAxes command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performModifyConstraintAxes(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: restrictAxesOptions; break; // Return the command string. // case 2: // Retrieve the option settings. // setOptionVars (false); // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }