// =========================================================================== // 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. // =========================================================================== // // Description: // This script is use to display a option for Pose Editor // reate connection. // proc string assembleCmd() { string $cmd; string $srcAttr = `optionVar -q PENCsrcAttr`; string $destAttr = `optionVar -q PENCdest`; $cmd = "connectAttr " + $srcAttr + " " + $destAttr; return $cmd; } global proc PoseEditorNewConnectionCallback(string $parent, int $doIt) { setParent $parent; $bsd = (`optionMenuGrp -q -ni pencBlendShapeDeformerMenuGrp` == 0)? "": `optionMenuGrp -q -value pencBlendShapeDeformerMenuGrp`; optionVar -sv PENCbsd $bsd; $tgt = (`optionMenuGrp -q -ni pencTargetMenuGrp` == 0)? "": `optionMenuGrp -q -value pencTargetMenuGrp`; optionVar -sv PENCtgt $tgt; $dest = `textFieldGrp -q -text pencConnDestFieldGrp`; optionVar -sv PENCdest $dest; if ($doIt) { $cmd = `assembleCmd`; eval($cmd); } } global proc PoseEditorNewConnectionSetup(string $parent, int $forceFactorySettings) { setParent $parent; if($forceFactorySettings) { optionVar -sv PENCbsd ""; optionVar -sv PENCtgt ""; optionVar -sv PENCdest ""; } $bsdL = `ls -type blendShape`; string $bsd = (`optionVar -ex PENCbsd`) ? `optionVar -q PENCbsd` : ""; if(`optionMenuGrp -q -ni pencBlendShapeDeformerMenuGrp` != 0) { if($bsd == "") optionMenuGrp -e -select 1 pencBlendShapeDeformerMenuGrp; else if(stringArrayFind($bsd, 0, $bsdL) >= 0) optionMenuGrp -e -value $bsd pencBlendShapeDeformerMenuGrp; } pencBsdChanged(1); } global proc pencBsdChanged(int $init) { //Update target menu $items = `optionMenuGrp -q -ill pencTargetMenuGrp`; for($item in $items) deleteUI $item; $bsd = (`optionMenuGrp -q -ni pencBlendShapeDeformerMenuGrp` == 0)? "": `optionMenuGrp -q -value pencBlendShapeDeformerMenuGrp`; if($bsd == "") return; string $tgts[] = eval("listAttr -m " + $bsd + ".weight"); $tgts = sort($tgts); setParent pencTargetMenuGrp; for($tgt in $tgts) menuItem -label $tgt; if($init) { if(`optionMenuGrp -q -ni pencTargetMenuGrp` != 0) { $tgt = `optionVar -q PENCtgt`; if($tgt == "") optionMenuGrp -e -select 1 pencTargetMenuGrp; else if(stringArrayFind($tgt, 0, $tgts) >= 0) optionMenuGrp -e -value $tgt pencTargetMenuGrp; } } pencTgtChanged; } global proc pencTgtChanged() { textFieldGrp -e -text "" pencConnDestFieldGrp; if((`optionMenuGrp -q -ni pencBlendShapeDeformerMenuGrp` == 0)|| (`optionMenuGrp -q -ni pencTargetMenuGrp` == 0)) return; $bsd = `optionMenuGrp -q -value pencBlendShapeDeformerMenuGrp`; $tgt = `optionMenuGrp -q -value pencTargetMenuGrp`; if($bsd == "" || $tgt == "") return; textFieldGrp -e -text ($bsd+"."+$tgt) pencConnDestFieldGrp; } proc poseEditorNewConnectionOptions() { // Name of the command for this option box. // string $commandName = "PoseEditorNewConnection"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: 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; // STEP 2: Pass the command name to the option box. // ================================================= // // Any default option box behaviour based on the command name is set // up with this call. For example, updating the 'Help' menu item with // the name of the command. // setOptionBoxCommandName($commandName); // STEP 3: Activate the default UI template. // ========================================== // // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; string $parent = `columnLayout -adjustableColumn 1`; formLayout; columnLayout -adjustableColumn true; optionMenuGrp -label (uiRes("m_poseEditorNewConnectionWindow.kBlendShapeDeformer")) -changeCommand "pencBsdChanged(0)" pencBlendShapeDeformerMenuGrp; $bsdL = `ls -type blendShape`; $bsdL = sort($bsdL); for($bsd in $bsdL) menuItem -label $bsd; optionMenuGrp -label (uiRes("m_poseEditorNewConnectionWindow.kTarget")) -changeCommand "pencTgtChanged" pencTargetMenuGrp; //setParent ..; formLayout -height 5; // Space setParent ..; textFieldGrp -label (uiRes("m_poseEditorNewConnectionWindow.kConnection")) pencConnDestFieldGrp; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // Provide more descriptive labels for the buttons. This is not // necessary, but in some cases, for example, a button labelled // 'Create' may be more meaningful to the user than one labelled // 'Apply'. // // Disable those buttons that are not applicable to the option box. // // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_poseEditorNewConnectionWindow.kAddConnection")) -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; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_poseEditorNewConnectionWindow.kAddPoseShapeConnection")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag($commandName); // Step 9: Set the current values of the option box. // ================================================= // eval(($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } global proc poseEditorNewConnectionWindow(string $sourceAttr) // // Description: // Create window "Add Pose Shape Connection". // Used to connection from source attribute to a target attribute // // Input Arguments: // string $sourceAttr -Given source attribute on interpolator node // { optionVar -sv PENCsrcAttr $sourceAttr; poseEditorNewConnectionOptions; }