// =========================================================================== // 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 remove constraint targets. // // 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 removeAllTargets`) { optionVar -intValue removeAllTargets 1; } if ($forceFactorySettings || !`optionVar -exists removeTargetAddTargets`) { optionVar -intValue removeTargetAddTargets 1; } if ($forceFactorySettings || !`optionVar -exists aimConstraintAddTargets`) { optionVar -intValue aimConstraintAddTargets 1; } if ($forceFactorySettings || !`optionVar -exists orientConstraintAddTargets`) { optionVar -intValue orientConstraintAddTargets 1; } if ($forceFactorySettings || !`optionVar -exists scaleConstraintAddTargets`) { optionVar -intValue scaleConstraintAddTargets 1; } if ($forceFactorySettings || !`optionVar -exists parentConstraintAddTargets`) { optionVar -intValue parentConstraintAddTargets 1; } if ($forceFactorySettings || !`optionVar -exists geometryConstraintAddTargets`) { optionVar -intValue geometryConstraintAddTargets 1; } if ($forceFactorySettings || !`optionVar -exists normalConstraintAddTargets`) { optionVar -intValue normalConstraintAddTargets 1; } if ($forceFactorySettings || !`optionVar -exists tangentConstraintAddTargets`) { optionVar -intValue tangentConstraintAddTargets 1; } if ($forceFactorySettings || !`optionVar -exists poleVectorConstraintAddTargets`) { optionVar -intValue poleVectorConstraintAddTargets 1; } if ($forceFactorySettings || !`optionVar -exists pointOnPolyConstraintAddTargets`) { optionVar -intValue pointOnPolyConstraintAddTargets 1; } // maintain existing offset // if ($forceFactorySettings || !`optionVar -exists remConstMaintainOffset`) { optionVar -intValue remConstMaintainOffset 0; } } // // Procedure Name: // removeTargetSetup // // 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 removeTargetSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; if (`optionVar -query removeAllTargets`) { checkBoxGrp -edit -value1 1 removeAllTargetsWidget; dimAllConstraintsCallback($parent,1); } checkBoxGrp -edit -value1 (`optionVar -query pointConstraintAddTargets`) pointConstraintRemWidget; checkBoxGrp -edit -value1 (`optionVar -query orientConstraintAddTargets`) orientConstraintRemWidget; checkBoxGrp -edit -value1 (`optionVar -query aimConstraintAddTargets`) aimConstraintRemWidget; checkBoxGrp -edit -value1 (`optionVar -query orientConstraintAddTargets`) orientConstraintRemWidget; checkBoxGrp -edit -value1 (`optionVar -query scaleConstraintAddTargets`) scaleConstraintRemWidget; checkBoxGrp -edit -value1 (`optionVar -query parentConstraintAddTargets`) parentConstraintRemWidget; checkBoxGrp -edit -value1 (`optionVar -query geometryConstraintAddTargets`) geometryConstraintRemWidget; checkBoxGrp -edit -value1 (`optionVar -query normalConstraintAddTargets`) normalConstraintRemWidget; checkBoxGrp -edit -value1 (`optionVar -query tangentConstraintAddTargets`) tangentConstraintRemWidget; checkBoxGrp -edit -value1 (`optionVar -query poleVectorConstraintAddTargets`) poleVectorConstraintRemWidget; checkBoxGrp -edit -value1 (`optionVar -query pointOnPolyConstraintAddTargets`) pointOnPolyConstraintRemWidget; checkBoxGrp -edit -value1 `optionVar -query remConstMaintainOffset` removeConstraintMaintainWidget; } // // Procedure Name: // removeTargetCallback // // 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 removeTargetCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. optionVar -intValue removeAllTargets `checkBoxGrp -query -value1 removeAllTargetsWidget`; optionVar -intValue removeTargetAddTargets `checkBoxGrp -query -value1 pointConstraintRemWidget`; optionVar -intValue aimConstraintAddTargets `checkBoxGrp -query -value1 aimConstraintRemWidget`; optionVar -intValue orientConstraintAddTargets `checkBoxGrp -query -value1 orientConstraintRemWidget`; optionVar -intValue scaleConstraintAddTargets `checkBoxGrp -query -value1 scaleConstraintRemWidget`; optionVar -intValue parentConstraintAddTargets `checkBoxGrp -query -value1 parentConstraintRemWidget`; optionVar -intValue geometryConstraintAddTargets `checkBoxGrp -query -value1 geometryConstraintRemWidget`; optionVar -intValue normalConstraintAddTargets `checkBoxGrp -query -value1 normalConstraintRemWidget`; optionVar -intValue poleVectorConstraintAddTargets `checkBoxGrp -query -value1 poleVectorConstraintRemWidget`; optionVar -intValue tangentConstraintAddTargets `checkBoxGrp -query -value1 tangentConstraintRemWidget`; optionVar -intValue pointOnPolyConstraintAddTargets `checkBoxGrp -query -value1 pointOnPolyConstraintRemWidget`; // maintain offset // optionVar -intValue remConstMaintainOffset `checkBoxGrp -query -value1 removeConstraintMaintainWidget`; if ($doIt) { performRemoveConstraintTarget 0; addToRecentCommandQueue "performRemoveConstraint 0" "RemoveConstraint"; } } // // Procedure Name: // dimAllConstraintsCallback // // Description: // Dim or undim offset UI based on whether or not we are in // "all constraint" mode. // // Input Arguments: // parent - Top level parent layout of the option box UI. // // Return Value: // None. // global proc dimAllConstraintsCallback(string $parent, int $state) { setParent $parent; int $dim = ($state==0); checkBoxGrp -edit -enable $dim pointConstraintRemWidget; checkBoxGrp -edit -enable $dim aimConstraintRemWidget; checkBoxGrp -edit -enable $dim orientConstraintRemWidget; checkBoxGrp -edit -enable $dim scaleConstraintRemWidget; checkBoxGrp -edit -enable $dim parentConstraintRemWidget; checkBoxGrp -edit -enable $dim geometryConstraintRemWidget; checkBoxGrp -edit -enable $dim tangentConstraintRemWidget; checkBoxGrp -edit -enable $dim normalConstraintRemWidget; checkBoxGrp -edit -enable $dim poleVectorConstraintRemWidget; checkBoxGrp -edit -enable $dim pointOnPolyConstraintRemWidget; } // // Procedure Name: // removeTargetOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc removeTargetOptions() { // Name of the command for this option box. // string $commandName = "removeTarget"; // 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_performRemoveConstraintTarget.kConstraintType")) -label1 (uiRes("m_performRemoveConstraintTarget.kAll")) -annotation (uiRes("m_performRemoveConstraintTarget.kConstraintTypeAnnot")) -numberOfCheckBoxes 1 -cc ("dimAllConstraintsCallback "+ $parent + " #1") removeAllTargetsWidget; checkBoxGrp -label "" -label1 (uiRes("m_performRemoveConstraintTarget.kPointConstraint")) -annotation (uiRes("m_performRemoveConstraintTarget.kTPointConstraintAnnot")) -numberOfCheckBoxes 1 pointConstraintRemWidget; checkBoxGrp -label "" -label1 (uiRes("m_performRemoveConstraintTarget.kAimConstraint")) -annotation (uiRes("m_performRemoveConstraintTarget.kAimConstraintAnnot")) -numberOfCheckBoxes 1 aimConstraintRemWidget; checkBoxGrp -label "" -label1 (uiRes("m_performRemoveConstraintTarget.kOrientConstraint")) -annotation (uiRes("m_performRemoveConstraintTarget.kTOrientConstraintAnnot")) -numberOfCheckBoxes 1 orientConstraintRemWidget; checkBoxGrp -label "" -label1 (uiRes("m_performRemoveConstraintTarget.kScaleConstraint")) -annotation (uiRes("m_performRemoveConstraintTarget.kScaleConstraintAnnot")) -numberOfCheckBoxes 1 scaleConstraintRemWidget; checkBoxGrp -label "" -label1 (uiRes("m_performRemoveConstraintTarget.kParentConstraint")) -annotation (uiRes("m_performRemoveConstraintTarget.kParentConstraintAnnot")) -numberOfCheckBoxes 1 parentConstraintRemWidget; checkBoxGrp -label "" -label1 (uiRes("m_performRemoveConstraintTarget.kGeometryConstraint")) -annotation (uiRes("m_performRemoveConstraintTarget.kGeometryConstraintAnnot")) -numberOfCheckBoxes 1 geometryConstraintRemWidget; checkBoxGrp -label "" -label1 (uiRes("m_performRemoveConstraintTarget.kNormalConstraint")) -annotation (uiRes("m_performRemoveConstraintTarget.kNormalConstraintAnnot")) -numberOfCheckBoxes 1 normalConstraintRemWidget; checkBoxGrp -label "" -label1 (uiRes("m_performRemoveConstraintTarget.kTangentConstraint")) -annotation (uiRes("m_performRemoveConstraintTarget.kTangentConstraintAnnot")) -numberOfCheckBoxes 1 tangentConstraintRemWidget; checkBoxGrp -label "" -label1 (uiRes("m_performRemoveConstraintTarget.kPoleVectorConstraint")) -annotation (uiRes("m_performRemoveConstraintTarget.kPoleVectorConstraintAnnot")) -numberOfCheckBoxes 1 poleVectorConstraintRemWidget; checkBoxGrp -label "" -label1 (uiRes("m_performRemoveConstraintTarget.kPointOnPolyConstraint")) -annotation (uiRes("m_performRemoveConstraintTarget.kTPointOnPolyConstraintAnnot")) -numberOfCheckBoxes 1 pointOnPolyConstraintRemWidget; checkBoxGrp -label (uiRes("m_performRemoveConstraintTarget.kMaintainOffset")) -label1 "" -annotation (uiRes("m_performRemoveConstraintTarget.kMaintainOffsetAnnot")) -numberOfCheckBoxes 1 removeConstraintMaintainWidget; // 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_performRemoveConstraintTarget.kRemoveButton")) -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_performRemoveConstraintTarget.kRemoveTargetOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "RemoveTarget" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } // // Procedure Name: // removeTargetHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string removeTargetHelp() { return (" Command: Remove Constraint Targets - removes target from 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 = "doRemoveConstraintTarget 1 "; setOptionVars(false); if (`optionVar -q removeAllTargets`) { int $maintainOffset = `optionVar -q remConstMaintainOffset`; $cmd = ($cmd + " { " + "\"" + "all" + "\"" + ",\""+$maintainOffset + "\"" + "};"); } else { string $which[]; if (`optionVar -query removeTargetAddTargets`) { $which[size($which)] = "point"; } if (`optionVar -query aimConstraintAddTargets`) { $which[size($which)] = "aim"; } if (`optionVar -query orientConstraintAddTargets`) { $which[size($which)] = "orient"; } if (`optionVar -query scaleConstraintAddTargets`) { $which[size($which)] = "scale"; } if (`optionVar -query parentConstraintAddTargets`) { $which[size($which)] = "parent"; } if (`optionVar -query geometryConstraintAddTargets`) { $which[size($which)] = "geometry"; } if (`optionVar -query normalConstraintAddTargets`) { $which[size($which)] = "normal"; } if (`optionVar -query tangentConstraintAddTargets`) { $which[size($which)] = "tangent"; } if (`optionVar -query poleVectorConstraintAddTargets`) { $which[size($which)] = "poleVector"; } if (`optionVar -query pointOnPolyConstraintAddTargets`) { $which[size($which)] = "pointOnPoly"; } int $ii; string $constraintList; int $numConstraints = size($which); for ($ii = 0; $ii < $numConstraints; $ii++) { $constraintList += $which[$ii]; if ($ii != ($numConstraints-1)) { $constraintList += ","; } } int $maintainOffset = `optionVar -q remConstMaintainOffset`; $cmd = ($cmd + " { " + "\"" + $constraintList + "\"" + ",\""+$maintainOffset + "\"" + "};"); } return $cmd; } // // Procedure Name: // performRemoveConstraintTarget // // Description: // Perform the removeTarget 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 removeTarget 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 performRemoveConstraintTarget(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: removeTargetOptions; break; // Return the command string. // case 2: // Retrieve the option settings. // setOptionVars (false); // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }