// =========================================================================== // 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 BlendShapeAddCombinationTarget 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 seAddCombTgtTgtType`) { optionVar -floatValue seAddCombTgtTgtType 1; } if ($forceFactorySettings || !`optionVar -exists seAddCombTgtTransformName`) { optionVar -stringValue seAddCombTgtTransformName ""; } if ($forceFactorySettings || !`optionVar -exists seAddCombTgtCombMtd`) { optionVar -intValue seAddCombTgtCombMtd 1; } } // // Procedure Name: // BlendShapeAddCombinationTargetSetup // // 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 BlendShapeAddCombinationTargetSetup(string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; int $type=`optionVar -q seAddCombTgtTgtType`; optionMenuGrp -e -sl $type seAddCombTgtTgtTypeList; $transformName = `optionVar -query seAddCombTgtTransformName`; textFieldButtonGrp -edit -text $transformName seAddCombTgtTransformNameFBGrp; $method = `optionVar -q seAddCombTgtCombMtd`; optionMenuGrp -e -select $method seAddCombTgtCombMtdGrp; seAddCombTgtDeformerModeCallBack(); } // // Procedure Name: // seAddCombTgtDeformerModeCallBack // // Description: // Update state of seAddCombTgtTransformNameFBGrp by selection in seAddCombTgtTgtTypeList. // Return Value: // None. // global proc seAddCombTgtDeformerModeCallBack() { int $selectItem = `optionMenuGrp -q -select seAddCombTgtTgtTypeList`; if ($selectItem == 4) // transform space textFieldButtonGrp -e -enable 1 seAddCombTgtTransformNameFBGrp; else textFieldButtonGrp -e -enable 0 seAddCombTgtTransformNameFBGrp; } // // Procedure Name: // seAddCombTgtTransformCallBack // // Description: // Update transform object // Return Value: // None. // global proc seAddCombTgtTransformCallBack(string $textFieldName) { string $selection[] = `ls -sl -type "transform"`; if(size($selection)) textFieldButtonGrp -e -text $selection[0] -forceChangeCommand $textFieldName; else print (uiRes("m_performCombinationTargetAdd.kNoTransformSelected")) ; } // // Procedure Name: // BlendShapeAddCombinationTargetCallback // // 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 BlendShapeAddCombinationTargetCallback(string $parent, int $doIt) { setParent $parent; int $type= `optionMenuGrp -q -select seAddCombTgtTgtTypeList`; optionVar -intValue seAddCombTgtTgtType $type; $transformName = `textFieldButtonGrp -q -text seAddCombTgtTransformNameFBGrp`; optionVar -stringValue seAddCombTgtTransformName $transformName; $combineMethod = `optionMenuGrp -q -select seAddCombTgtCombMtdGrp`; optionVar -intValue seAddCombTgtCombMtd $combineMethod; if ($doIt) { string $cmd = "performCombinationTargetAdd 0"; eval($cmd); addToRecentCommandQueue $cmd "BlendShapeAddCombinationTarget"; } } // // Procedure Name: // seAddCombTgtOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc seAddCombTgtOptions() { // Name of the command for this option box // string $commandName = "BlendShapeAddCombinationTarget"; // 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_performCombinationTargetAdd.kType")) -changeCommand("seAddCombTgtDeformerModeCallBack") seAddCombTgtTgtTypeList; menuItem -label (uiRes("m_performCombinationTargetAdd.kAutomatic")); menuItem -label (uiRes("m_performCombinationTargetAdd.kObjectSpace")); menuItem -label (uiRes("m_performCombinationTargetAdd.kPDMTangentSpace")); menuItem -label (uiRes("m_performCombinationTargetAdd.kPDMTransformSpace")); textFieldButtonGrp -label (uiRes("m_performCombinationTargetAdd.kTransformName")) -editable true -buttonLabel (uiRes("m_performCombinationTargetAdd.kUseSelected")) -text "" -cw 3 100 -buttonCommand("seAddCombTgtTransformCallBack(\"seAddCombTgtTransformNameFBGrp\")") seAddCombTgtTransformNameFBGrp; textFieldButtonGrp -e -enable 0 seAddCombTgtTransformNameFBGrp; separator; optionMenuGrp -label (uiRes("m_performCombinationTargetAdd.kCombineMethod")) -columnAlign 1 "right" seAddCombTgtCombMtdGrp; menuItem -l (uiRes("m_performCombinationTargetAdd.kMultiplication")) "Multiplication"; menuItem -l (uiRes("m_performCombinationTargetAdd.kLowestWeighting")) "LowestWeighing"; menuItem -l (uiRes("m_performCombinationTargetAdd.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_performCombinationTargetAdd.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 seAddCombTgtTgtType`; string $transform = "\"\""; if($tgtType == 4)//Transform Space, check joint { $transform = `optionVar -q seAddCombTgtTransformName`; if($transform == "") { error((uiRes("m_performCombinationTargetAdd.kNoJointSelected"))); return $cmd; } } int $combineMethod = `optionVar -q seAddCombTgtCombMtd` - 1; $cmd = "doCombinationShapeCreate 1 " + $combineMethod + " " + $tgtType + " " + $transform; return $cmd; } // // Procedure Name: // performCombinationTargetAdd // // Description: // Perform the BlendShapeAddCombinationTarget 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 performCombinationTargetAdd (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 seAddCombTgtOptions; break; case 2: // Return the drag string // Retrieve the option settings // setOptionVars (false); // Get the command $cmd = `assembleCmd`; break; } return $cmd; }