// =========================================================================== // 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 14 1997 // // // // // // gotoBindPose() // // // This script moves all selected skeletons to the bindPose. // // // // select -r joeHip maryHip; // gotoBindPose; // // // global proc gotoBindPose() { // For each selected transform ... string $selTransforms[] = `ls -sl -type transform`; for ($obj in $selTransforms) { // Query the bindPose connected to the object ... string $bindPoses[] = `dagPose -q -bp $obj`; // ... and restore it (if only one bindPose is found). // if(size($bindPoses) == 1) { catch(`dagPose -r -g -bp $obj`); continue; } // If multiple bindposes are found use the skinCluster object to determine // which of bindPose should be restored. // // First check if a shape exists and bail if no shape can be found. // string $shapes[] = `listRelatives -path -noIntermediate -shapes $obj`; if(size($shapes) == 0) { string $fmt = (uiRes("m_gotoBindPose.kErrorNoShape")); error(`format -s $obj $fmt`); } // If a shape is found, find the all bindPoses connected to the skinCluster. // string $skinClusterName = findRelatedSkinCluster($shapes[0]); string $skinBindPosePlug = $skinClusterName + ".bindPose"; string $bindPose[] = `listConnections -d false -s true -type dagPose $skinBindPosePlug`; if(size($bindPose) > 0){ catch(`dagPose -r -g $bindPose[0]`); } else { // Otherwise, handle legacy scenes ... //for legacy scenes (prior to Maya 2008) the skin cluster may not be connected //to the bindpose. In this case we'll have to try to find the bind pose a //different way. string $influences[] = `skinCluster -q -inf $skinClusterName`; for($inf in $influences) { $bindPose = `dagPose -q -bp $inf`; if(size($bindPose)== 0) continue; catch(`dagPose -r -g $bindPose[0]`); break; } } } }