// =========================================================================== // 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 BlendShapeAddTarget 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 seAddTgtTgtType`) { optionVar -floatValue seAddTgtTgtType 1; } if ($forceFactorySettings || !`optionVar -exists seAddTgtTransformName`) { optionVar -stringValue seAddTgtTransformName ""; } } // // Procedure Name: // BlendShapeAddTargetSetup // // 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 BlendShapeAddTargetSetup(string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; int $type=`optionVar -q seAddTgtTgtType`; optionMenuGrp -e -sl $type seAddTgtTgtTypeList; $transformName = `optionVar -query seAddTgtTransformName`; textFieldButtonGrp -edit -text $transformName seAddTgtTransformNameFBGrp; seAddTgtDeformerModeCallBack(); } // // Procedure Name: // seAddTgtDeformerModeCallBack // // Description: // Update state of seAddTgtTransformNameFBGrp by selection in seAddTgtTgtTypeList. // Return Value: // None. // global proc seAddTgtDeformerModeCallBack() { int $selectItem = `optionMenuGrp -q -select seAddTgtTgtTypeList`; if ($selectItem == 4) // transform space textFieldButtonGrp -e -enable 1 seAddTgtTransformNameFBGrp; else textFieldButtonGrp -e -enable 0 seAddTgtTransformNameFBGrp; } // // Procedure Name: // seAddTgtTransformCallBack // // Description: // Update transform object // Return Value: // None. // global proc seAddTgtTransformCallBack(string $textFieldName) { string $selection[] = `ls -sl -type "transform"`; if(size($selection)) textFieldButtonGrp -e -text $selection[0] -forceChangeCommand $textFieldName; else print (uiRes("m_performTargetShapeAdd.kNoTransformSelected")) ; } // // Procedure Name: // BlendShapeAddTargetCallback // // 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 BlendShapeAddTargetCallback(string $parent, int $doIt) { setParent $parent; int $type= `optionMenuGrp -q -select seAddTgtTgtTypeList`; optionVar -intValue seAddTgtTgtType $type; $transformName = `textFieldButtonGrp -q -text seAddTgtTransformNameFBGrp`; optionVar -stringValue seAddTgtTransformName $transformName; if ($doIt) { string $cmd = "performTargetShapeAdd 0"; eval($cmd); addToRecentCommandQueue $cmd "BlendShapeAddTarget"; } } // // Procedure Name: // seAddTgtOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc seAddTgtOptions() { // Name of the command for this option box // string $commandName = "BlendShapeAddTarget"; // 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_performTargetShapeAdd.kType")) -changeCommand("seAddTgtDeformerModeCallBack") seAddTgtTgtTypeList; menuItem -label (uiRes("m_performTargetShapeAdd.kAutomatic")); menuItem -label (uiRes("m_performTargetShapeAdd.kObjectSpace")); menuItem -label (uiRes("m_performTargetShapeAdd.kPDMTangentSpace")); menuItem -label (uiRes("m_performTargetShapeAdd.kPDMTransformSpace")); textFieldButtonGrp -label (uiRes("m_performTargetShapeAdd.kTransformName")) -editable true -buttonLabel (uiRes("m_performTargetShapeAdd.kUseSelected")) -text "" -cw 3 100 -buttonCommand("seAddTgtTransformCallBack(\"seAddTgtTransformNameFBGrp\")") seAddTgtTransformNameFBGrp; textFieldButtonGrp -e -enable 0 seAddTgtTransformNameFBGrp; 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_performTargetShapeAdd.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 = ""; string $bsNodeName = getBlendShapeForAddTarget(); if($bsNodeName != "") { int $type=`optionVar -q seAddTgtTgtType`; string $transform = "\"\""; if($type == 4)//Transform Space, check joint { $transform = `optionVar -q seAddTgtTransformName`; if($transform == "") { error((uiRes("m_performTargetShapeAdd.kNoJointSelected"))); return $cmd; } } $cmd = "doBlendShapeAddTarget " + $bsNodeName + " 0 " + $type + " " + $transform + " 1 0 {}"; } return $cmd; } // // Procedure Name: // performTargetShapeAdd // // Description: // Perform the BlendShapeAddTarget 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 targetShapeAdd command with the current // option box values. // // Input Arguments: // 0 - do the command // 1 - show the option box // 2 - return the drag command // global proc string performTargetShapeAdd (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 seAddTgtOptions; break; case 2: // Return the drag string // Retrieve the option settings // setOptionVars (false); // Get the command $cmd = `assembleCmd`; break; } return $cmd; }