// =========================================================================== // 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 // // Description: // Given a plug that contains a blendShape target multiIndex, // return the target index // // Return: // If no multiIndex is found, returns -1. // global proc int bsTargetIndex(string $plug) { string $buffer[], $buffer2[]; tokenize($plug,"[",$buffer); if (size($buffer) < 4) { return(-1); } tokenize($buffer[2],"]",$buffer2); return $buffer2[0]; } // Find the 0-based index of the target on the blendShape. // Returns -1 if it cannot find the target. // global proc int getIndexForBlendShapeTarget(string $target, string $blendShape) { int $result = -1; int $ii; // find the index that corresponds to this target by // parsing the corresponding weight attribute index // string $aliasNames[] = `aliasAttr -q $blendShape`; string $tokens[]; tokenize $target ":" $tokens; // remove namespace, alias attr don't have them $target = $tokens[size($tokens) -1]; for ( $ii = 0; $ii < size($aliasNames); $ii += 2) { if ($aliasNames[$ii] == $target) { string $buffer[]; if (tokenize($aliasNames[$ii+1],"[",$buffer) == 2) { string $buffer2[]; tokenize($buffer[1],"]",$buffer2); $result = $buffer2[0]; } } } return $result; }