// =========================================================================== // 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: September, 1999 // // // // // // findRelatedSkinCluster (string $skinObj) // // // None // // // Script for finding a skin cluster that deforms the specified skin. // // // // To find the skinCluster for a skin called "johnBoy", type: // // findRelatedSkinCluster("johnBoy"); // // ///////////////////////////////////////////////////////////////////////// // global proc string findRelatedSkinCluster(string $skinObj) { string $skinShape; string $skinShapeWithPath; string $hiddenShape; string $hiddenShapeWithPath; string $cpTest[] = `ls -type controlPoint $skinObj`; if (size($cpTest)) { $skinShape = $skinObj; } else { string $rels[] = `listRelatives $skinObj`; for ($r in $rels) { $cpTest = `ls -type controlPoint ($skinObj+"|"+$r)`; if (0 == size($cpTest)) { continue; } int $io = `getAttr ($skinObj+"|"+$r+".io")`; if ($io) { continue; } int $visible = `getAttr ($skinObj+"|"+$r+".v")`; if (! $visible) { $hiddenShape = $r; $hiddenShapeWithPath = ($skinObj+"|"+$r); continue; } $skinShape = $r; $skinShapeWithPath = ($skinObj+"|"+$r); break; } } if (0 == size($skinShape)) { if (0 == size($hiddenShape)) { return ""; } else { $skinShape = $hiddenShape; $skinShapeWithPath = $hiddenShapeWithPath; } } string $clusters[] = `ls -type skinCluster`; for ($c in $clusters) { string $geom[] = `skinCluster -q -g $c`; for ($g in $geom) { if ($g == $skinShape || $g == $skinShapeWithPath) { return $c; } } } return ""; }