// =========================================================================== // 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: Dec 3, 1996 // // Description: // This script is a template script for option box dialogs. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { if( $forceFactorySettings || !`optionVar -exists bindSkinMethod` ) { optionVar -intValue bindSkinMethod 1; } if( $forceFactorySettings || !`optionVar -exists bindSkinTo` ) { optionVar -intValue bindSkinTo 1; } if( $forceFactorySettings || !`optionVar -exists bindSkinColorJts` ) { optionVar -intValue bindSkinColorJts 0; } // bindSkinMethod = to closest point (1) or to closest partition (2) // int $method = `optionVar -query bindSkinMethod`; if (2 == $method) { string $partitionName = `optionVar -q bindSkinPartition`; string $partitionExists[] = `ls -type partition $partitionName`; if (!size($partitionExists)) { // If the specified partition no longer exists, turn off the // optionVar for the method since it would fail anyway. // $method = 1; optionVar -intValue bindSkinMethod 1; } } } global proc bindSkinSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; // Query the optionVar's and set the values into the controls // int $method = `optionVar -query bindSkinMethod`; radioButtonGrp -e -sl $method bindSkinMethod; // bindSkinTo = to selected joints or to selected skeleton // optionMenuGrp -e -sl `optionVar -query bindSkinTo` bindSkinTo; // enable the partition list if by-partition ($method = 2) is chosen // int $enableList = ($method == 2); fillPartitionList; text -e -en $enableList partitionLabelText; textScrollList -e -en $enableList partitionScrollList; if ($method == 2) { textScrollList -e -si `optionVar -q bindSkinPartition` partitionScrollList; } // color joints option // int $colorJoints = `optionVar -query bindSkinColorJts`; checkBoxGrp -e -value1 $colorJoints bindSkinColorJtsWidget; } global proc bindSkinCallback (string $parent, int $doIt) // // Description: // Set the optionVar's from the control values, and then perform // the command // { setParent $parent; optionVar -intValue bindSkinTo `optionMenuGrp -q -sl bindSkinTo`; optionVar -intValue bindSkinMethod `radioButtonGrp -q -sl bindSkinMethod`; optionVar -intValue bindSkinColorJts `checkBoxGrp -q -value1 bindSkinColorJtsWidget`; if ($doIt) { performBindSkin false; addToRecentCommandQueue "performBindSkin false" "Bind Skin"; } } global proc updatePartitionCallback() { int $nsel = `textScrollList -q -nsi partitionScrollList`; if ($nsel > 0) { string $selected[] = `textScrollList -q -si partitionScrollList`; optionVar -stringValue bindSkinPartition $selected[0]; } } global proc fillPartitionList() { string $partitions[5] = `ls -type partition`; text -e -en 1 partitionLabelText; textScrollList -e -en 1 partitionScrollList; textScrollList -e -ra partitionScrollList; int $ii; int $pcount = size($partitions); for ($ii = 0; $ii < $pcount; $ii++) { textScrollList -e -a $partitions[$ii] partitionScrollList; } } proc string bindSkinBasic( string $tabLayout ) { setParent $tabLayout; string $tabForm = `columnLayout -adjustableColumn true`; optionMenuGrp -label (uiRes("m_performBindSkin.kBindTo")) bindSkinTo; menuItem -label (uiRes("m_performBindSkin.kCompleteSkeleton")) ; menuItem -label (uiRes("m_performBindSkin.kSelectedJoints")) ; menuItem -label (uiRes("m_performBindSkin.kForceAll")) ; setParent -m ..; optionMenuGrp -e -sl 1 bindSkinTo; checkBoxGrp -label (uiRes("m_performBindSkin.kColoring")) -label1 (uiRes("m_performBindSkin.kColorJoints")) -numberOfCheckBoxes 1 bindSkinColorJtsWidget; radioButtonGrp -nrb 2 -label (uiRes("m_performBindSkin.kBindMethod")) -label1 (uiRes("m_performBindSkin.kClosestPoint")) -label2 (uiRes("m_performBindSkin.kPartitionSet")) bindSkinMethod; radioButtonGrp -edit -select 1 -cc1 "text -e -en false partitionLabelText; textScrollList -e -en false partitionScrollList; " -cc2 "text -e -en true partitionLabelText; fillPartitionList" bindSkinMethod; rowLayout -nc 2 -cw 1 170 -cw 2 280; text -label (uiRes("m_performBindSkin.kPartition")) -align "right" partitionLabelText; textScrollList -ams false -nr 6 -enable false -sc "updatePartitionCallback" partitionScrollList; setParent ..; text -e -en false partitionLabelText; return $tabForm; } global proc bindSkinOptions () { // Name of the command for this option box // string $commandName = "bindSkin"; // 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("bindSkin"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; bindSkinBasic $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performBindSkin.kBindSkin")) -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_performBindSkin.kRigidBindSkinOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "RigidBind" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } proc string assembleCmd () { string $cmd; setOptionVars( false ); $cmd = "newBindSkin \""; int $whichMethod = `optionVar -q bindSkinMethod`; switch( $whichMethod ) { case 1: { $cmd = ( $cmd + " -byClosestPoint" ); break; } case 2: { $cmd = ( $cmd + " -byPartition -partition " ); string $partitionName = `optionVar -q bindSkinPartition`; $cmd += $partitionName; break; } } int $colorJoints = `optionVar -q bindSkinColorJts`; if ($colorJoints) { $cmd = ( $cmd + " -colorJoints"); } int $bindTo = `optionVar -q bindSkinTo`; switch( $bindTo ) { case 1: $cmd = ( $cmd + " -toSkeleton" ); break; case 2: $cmd = ( $cmd + " -toSelectedBones" ); break; case 3: $cmd = ( $cmd + " -toAll" ); break; } $cmd += "\";"; return $cmd; } global proc string performBindSkin (int $action) // // The action variable means // 0 - do the command // 1 - show the option box // 2 - return the drag command // { 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 bindSkinOptions; break; case 2: // Return the drag string // Retrieve the option settings // setOptionVars (false); // Get the command $cmd = `assembleCmd`; break; } return $cmd; }