// =========================================================================== // 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: May 30, 2005 // // Procedure Name: // doTogglePinFBIKEffectors // // Description: // First determines what the pinning state is for the majority // of the selected effectors, then sets all of them to the // opposite of that state. // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // // $args // Version 1 // [0] $pinState 0/1/2 : if 0, pins translation, // if 1, pins rotation. // if 2, pins both translation and rotation // // Return Value: // none // global proc doTogglePinFBIKEffectors( string $version, string $args[] ) { int $versionNum = $version; int $pinWhich = $args[0]; int $effectorsPinned = 0; int $effectorsTranslatePinned = 0; int $effectorsRotatePinned = 0; int $totalEffectorsCount = 0; string $selItems[]; $selItems = `ls -sl`; // Determine how many effectors and their current overall pinned/unpinned state source loadFullBodyIKFunctions.mel; for ($item in $selItems) { if (`objectType $item` == "hikEffector") { $totalEffectorsCount++; if (getEffectorTranslatePinState($item)) { $effectorsTranslatePinned++; } if (getEffectorRotatePinState($item)) { $effectorsRotatePinned++; } } } //print ("Translate pinned " + $effectorsTranslatePinned + "\n"); //print ("Rotate pinned " + $effectorsRotatePinned + "\n"); //print ("Total effector count " + $totalEffectorsCount + "\n"); int $effectorsTranslateUnpinned = $totalEffectorsCount - $effectorsTranslatePinned; int $effectorsRotateUnpinned = $totalEffectorsCount - $effectorsRotatePinned; // Toggle pinning to the opposite of the current majority int $pinAllTranslates = ($effectorsTranslatePinned < $effectorsTranslateUnpinned); int $pinAllRotates = ($effectorsRotatePinned < $effectorsRotateUnpinned); // Unpin if everything is currently pinned, otherwise pin everything int $pinBoth = !(($effectorsTranslateUnpinned == 0) && ($effectorsRotateUnpinned == 0)); for ($item in $selItems) { if (`objectType $item` == "hikEffector") { switch ($pinWhich) { case 0: setEffectorTranslatePinState($item, $pinAllTranslates); break; case 1: setEffectorRotatePinState($item, $pinAllRotates); break; case 2: setEffectorTranslatePinState($item, $pinBoth); setEffectorRotatePinState($item, $pinBoth); break; default: string $printMsg = (uiRes("m_doTogglePinFBIKEffectors.kUnexpectedValue")); $printMsg = `format -s $pinWhich $printMsg`; print $printMsg; break; } } } }