// =========================================================================== // 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: June, 2000 // global proc int bsMultiIndexForTarget(string $bsn, int $wc) // // Description: // Return the multiIndex that corresponds to target $wc on $bsn. // { string $sArr[] = `ls -sl`; if (nodeType($bsn) != "blendShape") { // find the blendShape node: // $bsn may be either the blendShape node, or the transform // above the base shape of the blendShape // string $isType[] = `ls -type transform $bsn`; if (size($isType)) { string $children[] = `pickWalk -d down $bsn`; if (size($children)) { $bsn = $children[0]; } select -r $sArr; } $isType = `listConnections -type blendShape $bsn`; if (size($isType)) { $bsn = $isType[0]; } else { error((uiRes("m_bsMultiIndexForTarget.kNoBlendshape"))); return -1; } } // if final target index is being requested, search for the max target // int $maxTarget = 0; int $searchForMax = (`blendShape -q -wc $bsn` == ($wc+1)); string $allTargets[] = `listAttr -m -st "inputPointsTarget" ($bsn+".inputTarget")`; string $targets[]; for ($t in $allTargets) { // weed out the in-between targets // if ("" != `match "6000" $t` && "" != `match "inputPointsTarget" $t` ) { $targets[size($targets)] = $t; if ($searchForMax) { int $tmp = bsTargetIndex($t); if ($tmp > $maxTarget) { $maxTarget = $tmp; } } } } if (size($targets) <= $wc) { return -1; } int $targetIndex; if ($searchForMax) { $targetIndex = $maxTarget; } else { string $targetPlug = $targets[$wc]; $targetIndex = bsTargetIndex($targetPlug); } return $targetIndex; }