// =========================================================================== // 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. // =========================================================================== // // File: AEikSpringRestPoseControl.mel // // Description: // // Attribute Editor Template for the ikSpringSolverRestPose // control. Since ikSpringSolverRestPose is a dynamic attribute, // this provides dynamic support as well. // global proc AEikSpringRestPoseControlNew( string $nodeAttr ) { // Check for attribute existence. Only create the UI if the // attribute exists (dynamicAttr support) // if( !`objExists $nodeAttr` ) return; string $buffer[]; tokenize($nodeAttr, ".", $buffer); string $node = $buffer[0]; string $attr = $buffer[1]; setUITemplate -pst attributeEditorTemplate; columnLayout -columnAttach "both" 5 -rowSpacing 2 -columnWidth 420; string $poseForm = `formLayout -w 400 ($attr + "Form")`; string $poseLabel = `attributeName -nice $nodeAttr`; string $label = `text -label $poseLabel -align "right" -h 25 -w 110`; string $cmd = "ikSpringSolverRestPose " + $node; string $button = `button -label (uiRes("m_AEikSpringRestPoseControl.kSetToCurrentPose")) -h 25 -w 125 -c $cmd ($attr + "Button")`; formLayout -edit -attachForm $label "left" 10 -attachNone $label "right" -attachForm $label "top" 0 -attachNone $label "bottom" -attachControl $button "left" 5 $label -attachNone $button "right" -attachForm $button "top" 0 -attachNone $button "bottom" $poseForm; setParent ..; setUITemplate -ppt; } global proc AEikSpringRestPoseControlReplace( string $nodeAttr ) { string $buffer[]; tokenize($nodeAttr, ".", $buffer); string $node = $buffer[0]; string $attr = $buffer[1]; // Check for existence of attribute // int $attrExists = `objExists $nodeAttr`; // Check for existence of UI // string $layoutName = $attr + "Form"; int $uiExists = `formLayout -q -exists $layoutName`; // Now execute based on state // if( $uiExists && $attrExists ) { // Ensure the layout is visible // formLayout -e -vis true $layoutName; string $buttonName = $attr + "Button"; string $cmd = "ikSpringSolverRestPose " + $node; button -e -c $cmd $buttonName; } else if( $uiExists && !$attrExists ) { // Hide the UI // formLayout -e -vis false $layoutName; } else if( !$uiExists && $attrExists ) { // Create the UI // AEikSpringRestPoseControlNew( $nodeAttr ); } // In the case of (!$uiExists && !$attrExists) there is nothing to be done. // } global proc AEikSpringRestPoseControl( string $restPoseName ) { editorTemplate -callCustom "AEikSpringRestPoseControlNew" "AEikSpringRestPoseControlReplace" $restPoseName; }