// =========================================================================== // 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. // =========================================================================== // // hikCustomRigUtils.mel // // Description: // Utility methods for HIK Custom Rigs. Should not contain // any UI code. All code that references UI or triggers UI // updates should live in hikCustomRigUI.mel or // hikCustomRigOperations.mel // // For the named character, determine the number of connections to attributes with a given prefix. // This is used to determine the number of spine/neck links on the active character. // TODO: rename this method global proc int hikGetCharacterizedLinkCount( string $character, string $prefix ) { int $count = 0; string $a, $attrs[] = `listAttr $character`; for ( $a in $attrs ) if ( startsWith( $a, $prefix ) && size( `listConnections ( $character + "." + $a )` ) ) $count++; return $count; } // Map ids returned by the UI to a name global proc string hikCustomRigElementNameFromId( string $character, int $id ) { if ( $id < 0 ) return ""; if ( $id < hikGetNodeCount() ) return GetHIKNodeName( $id ); // Any ID greater that hikGetNodeCount ( 172 ) has a special meaning and // requires some additional processsing. switch( $id ) { case 1000: // ID 1000 always points to the last spine on the current character string $prefix = "Spine"; int $count = hikGetCharacterizedLinkCount( $character, $prefix ); return ( ( $count > 1 ) ? ( $prefix + ( $count-1 ) ) : ( $prefix ) ); default: return ""; } } // // Determine the type of the element with a specified id. // global proc string hikCustomRigElementTypeFromId( int $id ) { int $inx = intArrayFind( $id, 0, `hikCustomRigToolWidget -q -ids` ); if ( $inx == -1 ) return ""; string $types[] = `hikCustomRigToolWidget -q -ts`; return ( $types[ $inx ] ); }