// =========================================================================== // 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. // =========================================================================== // // // global proc breakRigidBodyConnections() // // This proc deletes all the connections to a rigid body that are not connections // from the solver. // { int $i, $j, $k; string $selObj[] = `ls -sl`; // For each object in the selection list, check to see if // and rigid bodies are present. // for ($i = 0; $i < size( $selObj ); $i++) { // Get a list of selected items and thier children. // string $kids[] = `ls -dag -leaf -showType $selObj[$i]`; // Check to see if we have any rigid bodies. // for ($j = 0; $j < size( $kids ); $j += 2) { // If a rigid body is found process it. // if ($kids[$j+1] == "rigidBody") { string $rigidName = $kids[$j] + ".choice"; string $bakeSimIndex = $kids[$j] + ".bakeSimulationIndex"; string $choiceList[] = `connectionInfo -dfs $rigidName`; // Get the choice node. // for ( $k = 0; $k < size( $choiceList ); $k++ ) { string $choiceNode[] = `ls -o $choiceList[$k]`; string $destination = $choiceNode[0] + ".input[1]"; string $source = `connectionInfo -sfd $destination`; if ( ( size( $source ) > 0 ) && ( size( $destination ) > 0 ) ) { disconnectAttr $source $destination; } $destination = $choiceNode[0] + ".input[2]"; $source = `connectionInfo -sfd $destination`; if ( ( size( $source ) > 0 ) && ( size( $destination ) > 0 ) ) { disconnectAttr $source $destination; } } // If there is a connection to the bake sim attribute then we have // been baked. Disconnect the connection to this attribute. // if ( $bakeSimIndex != -1 ) { string $source = `connectionInfo -sfd $bakeSimIndex`; if ( ( size( $source ) > 0 ) && ( size( $bakeSimIndex ) > 0 ) ) { disconnectAttr $source $bakeSimIndex; } // Reset the bake sim index. // setAttr $bakeSimIndex -1; } } } } }