// =========================================================================== // 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: 2003 // // Description: // Option box for createDynamicConstraint menu. // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // proc setOptionVars(int $forceFactorySettings) { if($forceFactorySettings || !`optionVar -exists createDynamicConstraintUseSets`) { optionVar -intValue createDynamicConstraintUseSets false; } } // // Procedure Name: // performCreateDynamicConstraintSetup // // 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 performCreateDynamicConstraintSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; checkBoxGrp -edit -value1 `optionVar -query createDynamicConstraintUseSets` createDynamicConstraintUseSets; } // // Procedure Name: // performCreateDynamicConstraintCallback // // 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 performCreateDynamicConstraintCallback(string $parent, int $doIt, string $type) { setParent $parent; optionVar -intValue createDynamicConstraintUseSets `checkBoxGrp -query -value1 createDynamicConstraintUseSets`; if( $doIt ) { performCreateDynamicConstraint 0 $type; } } // // Procedure Name: // createDynamicConstraintOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc createDynamicConstraintOptions( string $type ) { // Name of the command for this option box. // string $typeNames[] = { "transform", "pointToPoint", "pointToSurface", "slideOnSurface", "weldBorders", "force", "match", "tearableSurface", "disableCollision", "collisionExclusion" }; string $typeLabels[] = { (uiRes("m_performCreateDynamicConstraint.kTransformLabel")), (uiRes("m_performCreateDynamicConstraint.kPointToPointLabel")), (uiRes("m_performCreateDynamicConstraint.kPointToSurfaceLabel")), (uiRes("m_performCreateDynamicConstraint.kSlideOnSurfaceLabel")), (uiRes("m_performCreateDynamicConstraint.kWeldBordersLabel")), (uiRes("m_performCreateDynamicConstraint.kForceLabel")), (uiRes("m_performCreateDynamicConstraint.kMatchLabel")), (uiRes("m_performCreateDynamicConstraint.kTearableSurfaceLabel")), (uiRes("m_performCreateDynamicConstraint.kDisableCollisionLabel")), (uiRes("m_performCreateDynamicConstraint.kCollisionExclusionLabel"))}; string $commandName = "performCreateDynamicConstraint"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate DefaultTemplate; tabLayout -tv false -scr true; string $parent = `columnLayout -adjustableColumn 1`; checkBoxGrp -ncb 1 -label1 (uiRes("m_performCreateDynamicConstraint.kUseSets")) createDynamicConstraintUseSets; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCreateDynamicConstraint.kCreateConstraint")) -command ($callback + " " + $parent + " " + 1 + " " + $type) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + " " + $type +"; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // string $label = (uiRes("m_performCreateDynamicConstraint.kDefaultLabel")); int $numTypes = size($typeNames); int $typeIndex = 0; while( $typeIndex < $numTypes ){ if( $type == $typeNames[$typeIndex] ){ // Found the right type, use its label // $label = $typeLabels[$typeIndex]; break; } $typeIndex++; } setOptionBoxTitle($label); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "CreateDynamicConstraint" ); // Pop the UI template // setUITemplate -popTemplate; // Set the current values of the option box. // eval( $setup + " " + $parent + " " + 0 ); // Show the option box. // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd( string $type ) { setOptionVars(false); string $cmd = ("doCreateNConstraint " + $type + " " + (`optionVar -query createDynamicConstraintUseSets`) ); return $cmd; } // // Procedure Name: // performCreateDynamicConstraint // // Description: // Perform the 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 command with the current // option box values. // // Input Arguments: // action // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performCreateDynamicConstraint(int $action, string $type) { string $cmd = ""; switch ($action) { // Execute the command from option settings. // case 0: setOptionVars(false); $cmd = assembleCmd ($type); eval($cmd); break; // Show the option box. // case 1: createDynamicConstraintOptions( $type ); break; // Return the command string. // case 2: setOptionVars (false); $cmd = assembleCmd( $type ); break; } return $cmd; }