// =========================================================================== // 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. // =========================================================================== // // // // // // getAllChains // // // string[] chain : String array, one entry for each unique deformer chain found. // // // Returns all deformer chains in the scene. Each unique chain is // returned separately. Only deformers are returned, no auxiliary nodes. // The implicitely-created tweak nodes, however, are included. Node names // are separated by a space. For example, if we have the following two // deformer chains: // // pCubeShape1Orig->bend1->cluster1->pCubeShape1
// pConeShape1Orig->twist1->pConeShape1
// // then this method will return an array of size two, the entries being: // // string[0] = "bend1 cluster1 tweak1"
// string[1] = "twist1 tweak2"
// // // None // // // string $cube[] = `polyCube`; // string $cone[] = `polyCone`; // nonLinear -before -type bend; // select $cube[0]; // cluster -before; // select $cone[0]; // nonLinear -before -type twist; // getAllChains; // // Result: bend1 cluster1 tweak1 twist1 tweak2 // print $chains[0]; // // Result: bend1 cluster1 tweak1 // // print $chains[1]; // // Result: twist1 tweak2 // // //
// global proc string[] getAllChains() { int $i, $j; // Make a unique list of all geometries that are deformed in the scene. // string $dfms[] = `ls -type geometryFilter`; string $geoms[]; for ( $i = 0; $i < size( $dfms ); $i++ ) { string $g[] = `deformer -q -g $dfms[$i]`; for ( $j = 0; $j < size( $g ); $j++ ) { if ( !stringArrayContains( $g[$j], $geoms ) ) { $geoms[size( $geoms )] = $g[$j]; } } } // For each deformed geometry, build a set of deformer chains for // all possible paths. Each array entry is a space-separated list of // the deformers that deform each geometry. // string $chains[]; for ( $i = 0; $i < size( $geoms ); $i++ ) { string $chain[] = getChain( $geoms[$i] ); $chains[$i] = stringArrayToString( $chain, " " ); } return( $chains ); }