// =========================================================================== // 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: 2002 // // Description: Get selected or sole pond fluid node // proc int isUsablePond( string $fluid ){ int $solver = getAttr ($fluid + ".solver"); if( $solver < 2 ){ return false; } int $is2d = getAttr ($fluid + ".is2d"); if( $is2d == 0 ){ return false; } int $heightField = getAttr ($fluid + ".heightField"); if( !$heightField ){ return false; } int $opacityInput = getAttr ($fluid + ".opacityInput"); if( $opacityInput != 5 ){ return false; } int $densityMethod = getAttr ($fluid + ".densityMethod"); if( $densityMethod != 2 ){ return false; } return( true ); } global proc string getCurrentPond() { string $fluids[] = `ls -dag -type fluidShape`; string $noPondsStr = (uiRes("m_getCurrentPond.kNoPonds")); if( size($fluids) == 0 ){ warning($noPondsStr); return( "" ); } // If only one fluid node, and it is suitable then use it if( size( $fluids ) == 1 ){ if( isUsablePond( $fluids[0] ) ){ return( $fluids[0] ); } else { warning($noPondsStr); return( "" ); } } // There is more than one, so we need to disambiguate using the selection string $usablePond = ""; int $i; int $moreThanOneUsable = false; for( $i = 0; $i < size( $fluids ); $i++ ){ if( isUsablePond( $fluids[$i] ) ){ if( $usablePond == "" ){ $usablePond = $fluids[$i]; } else { $moreThanOneUsable = true; break; } } } if( $usablePond == "" ){ warning($noPondsStr); return( "" ); } if( !$moreThanOneUsable ){ return( $usablePond ); } // First check for selected fluids string $sel[] = `ls -sl -dag -type fluidShape`; if( size($sel) > 0 ){ if( isUsablePond( $sel[0] ) ){ return( $sel[0] ); } } warning((uiRes("m_getCurrentPond.kTooManyPonds"))); return( "" ); }