// =========================================================================== // 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: December 2004 // // // // Procedure Name: // artAttrBlendShapeToolScript // // Description: // Invoke the Paint Blend Shape Tool with or without options window. // // Input Arguments: // 4 ==> enter the tool (create if necessary) // 3 ==> property sheet box // // Return Value: // None. // global proc int[] artBlendShapeTargetIndex() // // This is called from the blendShapeUpdater fn to obtain // the index of selected target. // Return is [ not created ? -1 : ( base ? 1 : 0 ), targetIndex ] where targetIndex >= 0 or targetIndex = -(normalization group) // { source "bsTargetIndex.mel"; // if the proc gets called when the control is not // yet created return -1 if(`textScrollList -exists blendShapeTargetList` ){ string $target[] = `textScrollList -q -si blendShapeTargetList`; // get the name of the blendShape being painted // string $cmd = "artAttrCtx -q -attrSelected " + `currentCtx` ; string $attrSelected = eval($cmd); string $tokens[] ; if( tokenize( $attrSelected, ".", $tokens) == 3) { // if there is a parallel blender, gets its blendShape input(s) // string $bsNodes[] ; int $par = `getAttr ($tokens[1]+".pb")`; if ($par){ $bsNodes = `listConnections -s 1 -d 0 -t blendShape $tokens[1]`; } else { $bsNodes[0] = $tokens[1] ; } for($node in $bsNodes) { // the base weights target uses the blendshape name if ( $node == $target[0] ) return { 1, 0 }; int $result = getIndexForBlendShapeTarget($target[0],$node); if (-1 != $result) { return { 0, $result }; } if ( match( "norm[0-9]+", $target[0] ) == $target[0] ) { string $n = endString( $target[0], size($target[0])-4 ); int $v = $n; return { 0, -( $v ) }; } } } } return { -1, 0 }; } global proc string artAttrBlendShapeToolScript( int $setToTool ) // // Description : // 4 ==> enter the tool { source "artAttrCallback.mel"; artAttrSyncCurrentAttribute(); // Deformer Paint Weight Tool. string $tool = "artAttrBlendShapeContext"; makePaintable -activateAll false; makePaintable -activate true "blendShape" "baseWeights"; makePaintable -activate true "blendShape" "paintTargetWeights"; setArtAttrFilterLabel( (uiRes("m_artAttrToolScript.kFilterAll")) ); if( ! `artAttrCtx -exists $tool` ) { rememberCtxSettings `artAttrCtx -i1 "paintBlendshape.png" -whichTool "blendShapeWeights" $tool`; } setToolTo $tool; if( 3 == $setToTool ) { toolPropertyWindow; } else if( 4 != $setToTool ) { warning( (uiRes("m_artAttrBlendShapeToolScript.kWrongInput"))); } return $tool; }