// =========================================================================== // 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: November, 2014 // // Description: // This is the script used to implement menus for the generic // set and clear initial state menus // global proc performSetDynStartState( int $setStartState ) { // 0 = clear selected, 1 = set selected // nParticles, particles, and classic rigid bodies/constraints/solvers use saveInitialState // nCloth uses the nBase command // fluids need their options for setting the state, but we can clear their IS with ClearIitialState here // we do NOT want to use saveInitialState on nCloth, cause we'd get useless particle attrs saved // so we can't just use it on all selected // anyhow, we need to bread up the selected objects by type int $noNObjectSelected = 1; int $index; // First check for nParticles and particles - we can set or clear IS for these string $pSel[] = `ls -sl -dag -exactType nParticle -exactType particle`; for( $index = 0; $index < size($pSel); $index++ ){ $noNObjectSelected = 0; if( $setStartState ){ saveInitialState( $pSel[$index] ); } else { clearParticleStartState( $pSel[$index] ); } } // get all the explicitly selected rigid things, we can set IS but we can't clear it $pSel = `ls -sl -dag -exactType rigidConstraint -exactType rigidBody -exactType nParticle -exactType rigidSolver`; for( $index = 0; $index < size($pSel); $index++ ){ $noNObjectSelected = 0; if( $setStartState ){ saveInitialState( $pSel[$index] ); } } // we can clear IS for selected fluid things, but we need separate options to set it. $pSel = `ls -sl -dag -exactType fluidShape -exactType fluidTexture2D -exactType fluidTexture3D`; if( !$setStartState && (size($pSel) > 0) ){ ClearInitialState; $noNObjectSelected = 0; } // list all the meshes selected // string $mSel[] = `ls -sl -dag -type mesh -visible -noIntermediate`; // Search for all nucleus meshes, and set/clear start state as appropriate // string $mesh = ""; string $cloth = ""; for( $index = 0; $index < size($mSel); $index++ ){ string $meshSel = $mSel[$index]; $cloth = findTypeInHistory( $meshSel, "nCloth", 1, 1 ); if( $cloth != "" ){ $noNObjectSelected = 0; string $cmd = "nBase -e -" + ($setStartState?"stuff":"clear") + "Start " + $cloth; evalEcho( $cmd ); if( !$setStartState ){ // Force a refresh // dgdirty( $cloth + ".outputMesh" ); refresh -f; } } } if( $noNObjectSelected ){ if( $setStartState ){ error( (uiRes("m_performSetDynStartState.kUnableToSet"))); } else { error( (uiRes("m_performSetDynStartState.kUnableToClear"))); } } }