// =========================================================================== // 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: 2003 // // Description: Gets hairsystems that are directly selected or indirectly // through selected curves. // proc int appendUniqueEntry( string $new, string $array[] ) { // add string "new" to "array" if it is not already included int $len = size( $array ); int $i; for( $i = 0; $i < $len; $i++ ){ if( $new == $array[$i] ){ $new = ""; break; } } if( $new != "" ){ $array[$len] = $new; $len++; } return( $len ); } global proc string[] getSelectedHairSystems() { string $out[] = `ls -sl -dag -type hairSystem`; int $len = size( $out ); string $pfxHair[] = `ls -sl -dag -type pfxHair`; int $pfxHairLen = size( $pfxHair ); int $i; for( $i = 0; $i < $pfxHairLen; $i++ ){ string $hairSys = sourceNodeNameFromConnection($pfxHair[$i] + ".renderHairs" ); if( $hairSys != "" ){ $len = appendUniqueEntry( $hairSys, $out ); } } string $hCurves[] = getSelectedHairCurves(); int $numCurves = size( $hCurves ); for( $i = 0; $i < $numCurves; $i++ ){ string $curve = $hCurves[$i]; string $hairSys = ""; string $con[] = `connectionInfo -dfs ($curve + ".outHair")`; if( size($con) > 0 ){ string $buffer[]; int $numTokens = `tokenize $con[0] "." $buffer`; if( $numTokens > 1 ){ string $nType = `nodeType $buffer[0]`; if( $nType == "hairSystem"){ $hairSys = $buffer[0]; } } } if( $hairSys != "" ){ $len = appendUniqueEntry( $hairSys, $out ); } } return $out; }