// =========================================================================== // 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: May 9, 2016 // // Description: // This script provides an option box dialog for the BlendShapeAddSelectionAsCombinationTarget command. // // Input Arguments: // None. // // Return Value: // None. // // // 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 seAddSelAsCombTgtTgtType`) { optionVar -floatValue seAddSelAsCombTgtTgtType 1; } if ($forceFactorySettings || !`optionVar -exists seAddSelAsCombTgtTransformName`) { optionVar -stringValue seAddSelAsCombTgtTransformName ""; } if ($forceFactorySettings || !`optionVar -exists seAddSelAsCombTgtCombMtd`) { optionVar -intValue seAddSelAsCombTgtCombMtd 1; } } // // Procedure Name: // BlendShapeAddSelectionAsCombinationTargetSetup // // 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 BlendShapeAddSelectionAsCombinationTargetSetup(string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; int $type=`optionVar -q seAddSelAsCombTgtTgtType`; optionMenuGrp -e -sl $type seAddSelAsCombTgtTgtTypeList; $transformName = `optionVar -query seAddSelAsCombTgtTransformName`; textFieldButtonGrp -edit -text $transformName seAddSelAsCombTgtTransformNameFBGrp; $method = `optionVar -q seAddSelAsCombTgtCombMtd`; optionMenuGrp -e -select $method seAddSelAsCombTgtCombMtdGrp; seAddSelAsCombTgtDeformerModeCallBack(); } // // Procedure Name: // seAddSelAsCombTgtDeformerModeCallBack // // Description: // Update state of seAddSelAsCombTgtTransformNameFBGrp by selection in seAddSelAsCombTgtTgtTypeList. // Return Value: // None. // global proc seAddSelAsCombTgtDeformerModeCallBack() { int $selectItem = `optionMenuGrp -q -select seAddSelAsCombTgtTgtTypeList`; if ($selectItem == 4) // transform space textFieldButtonGrp -e -enable 1 seAddSelAsCombTgtTransformNameFBGrp; else textFieldButtonGrp -e -enable 0 seAddSelAsCombTgtTransformNameFBGrp; } // // Procedure Name: // seAddSelAsCombTgtTransformCallBack // // Description: // Update transform object // Return Value: // None. // global proc seAddSelAsCombTgtTransformCallBack(string $textFieldName) { string $selection[] = `ls -sl -type "transform"`; if(size($selection)) textFieldButtonGrp -e -text $selection[0] -forceChangeCommand $textFieldName; else print (uiRes("m_performCombinationTargetAddSelection.kNoTransformSelected")) ; } // // Procedure Name: // BlendShapeAddSelectionAsCombinationTargetCallback // // 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 BlendShapeAddSelectionAsCombinationTargetCallback(string $parent, int $doIt) { setParent $parent; int $type= `optionMenuGrp -q -select seAddSelAsCombTgtTgtTypeList`; optionVar -intValue seAddSelAsCombTgtTgtType $type; $transformName = `textFieldButtonGrp -q -text seAddSelAsCombTgtTransformNameFBGrp`; optionVar -stringValue seAddSelAsCombTgtTransformName $transformName; $combineMethod = `optionMenuGrp -q -select seAddSelAsCombTgtCombMtdGrp`; optionVar -intValue seAddSelAsCombTgtCombMtd $combineMethod; if ($doIt) { string $cmd = "performCombinationTargetAddSelection 0"; eval($cmd); addToRecentCommandQueue $cmd "BlendShapeAddSelectionAsCombinationTarget"; } } // // Procedure Name: // seAddSelAsCombTgtOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc seAddSelAsCombTgtOptions() { // Name of the command for this option box // string $commandName = "BlendShapeAddSelectionAsCombinationTarget"; // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // 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; setOptionBoxCommandName($commandName); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; optionMenuGrp -enable 1 -label (uiRes("m_performCombinationTargetAddSelection.kType")) -changeCommand("seAddSelAsCombTgtDeformerModeCallBack") seAddSelAsCombTgtTgtTypeList; menuItem -label (uiRes("m_performCombinationTargetAddSelection.kAutomatic")); menuItem -label (uiRes("m_performCombinationTargetAddSelection.kObjectSpace")); menuItem -label (uiRes("m_performCombinationTargetAddSelection.kPDMTangentSpace")); menuItem -label (uiRes("m_performCombinationTargetAddSelection.kPDMTransformSpace")); textFieldButtonGrp -label (uiRes("m_performCombinationTargetAddSelection.kTransformName")) -editable true -buttonLabel (uiRes("m_performCombinationTargetAddSelection.kUseSelected")) -text "" -cw 3 100 -buttonCommand("seAddSelAsCombTgtTransformCallBack(\"seAddSelAsCombTgtTransformNameFBGrp\")") seAddSelAsCombTgtTransformNameFBGrp; textFieldButtonGrp -e -enable 0 seAddSelAsCombTgtTransformNameFBGrp; separator; optionMenuGrp -label (uiRes("m_performCombinationTargetAddSelection.kCombineMethod")) -columnAlign 1 "right" seAddSelAsCombTgtCombMtdGrp; menuItem -l (uiRes("m_performCombinationTargetAddSelection.kMultiplication")) "Multiplication"; menuItem -l (uiRes("m_performCombinationTargetAddSelection.kLowestWeighting")) "LowestWeighing"; menuItem -l (uiRes("m_performCombinationTargetAddSelection.kSmooth")) "Smooth"; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -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_performCombinationTargetAddSelection.kTitle")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( $commandName ); // 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 $cmd = ""; int $tgtType=`optionVar -q seAddSelAsCombTgtTgtType`; string $transform = "\"\""; if($tgtType == 4)//Transform Space, check joint { $transform = `optionVar -q seAddSelAsCombTgtTransformName`; if($transform == "") { error((uiRes("m_performCombinationTargetAddSelection.kNoJointSelected"))); return $cmd; } } int $combineMethod = `optionVar -q seAddSelAsCombTgtCombMtd` - 1; $cmd = "doBlendShapeAddSelectionAsCombinationTarget " + $combineMethod + " " + $tgtType + " " + $transform; return $cmd; } // // Procedure Name: // performCombinationTargetAddSelection // // Description: // Perform the BlendShapeAddSelectionAsCombinationTarget command using the // corresponding option values. This procedure will also show the option // box window if necessary. // // Input Arguments: // action - 0 - do the command // 1 - show the option box // 2 - return the drag command // global proc string performCombinationTargetAddSelection (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 seAddSelAsCombTgtOptions; break; case 2: // Return the drag string // Retrieve the option settings // setOptionVars (false); // Get the command $cmd = `assembleCmd`; break; } return $cmd; }