// =========================================================================== // 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: Jan 26, 1999 // // Description: // This script returns the weights of the selected // smooth skin components/objects to their default value // // Input Arguments: // None. // // Return Value: // None. // global proc performResetToDefault() // // Description: // This procedure returns the smooth skin weights of the // selected objects/components to their default values by executing // the "skinPercent -rtd $skinCluster" command. It uses the // current selection list to extract the objects and components. // When transforms are selected then the whole hierarchy of skinned // surfaces under them will be included in the command. // { // Find all the selected components // string $sel[] = `ls -sl`; // Find the selected shapes // string $allShapes[] = `ls -sl -lf -dag -o`; string $shape; int $count = 0; for ($shape in $allShapes) { // Ignore if it is an intermediate object // int $io = `getAttr ($shape+".io")`; if ($io == 1) continue; string $parentL[] = `listRelatives -parent $shape`; string $parent = $parentL[0]; // Get the skinCluster attached to the object // string $skinCluster = findRelatedSkinCluster($shape); if ($skinCluster == "") continue; // Loop though all the selected components // and select the ones that are related to the current shape // select -cl; string $comp; string $buf[]; for ($comp in $sel) { int $tok = tokenize($comp,".",$buf); // Component // if ($tok == 2 && $buf[0] == $parent) select -add $comp; // Whole shape // if ($tok == 1 && $buf[0] == $parent) { select -r $parent; break; } } // If the selection list is empty then select the // whole shape // string $newSel[] = `ls -sl`; if (size($newSel)== 0) select -r $parent; // Execute the command for the given skin cluster // string $cmd = "skinPercent -rtd "+ $skinCluster; catch(evalEcho($cmd)); $count++; } // Reset the selection // select -r $sel; if ($count == 0) { error( (uiRes("m_performResetToDefault.kNoSkinned"))); } }