// =========================================================================== // 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. // =========================================================================== // // // ==================== makeRigidActive.mel ========== // // SYNOPSIS // Create a rigid body, either active or passive, // depending on $cmdType. // global proc int makeRigidActive( int $cmdType ) { string $cmdString; string $selObj[] = `ls -sl`; int $isRigid = 0; if ( $cmdType ) { $cmdString = "-active"; } else { $cmdString = "-passive"; } for ($i = 0; $i < size( $selObj ); $i++) { string $leaves[] = `ls -dag -leaf -showType $selObj[$i]`; $isRigid = 0; for ($j = 0; $j < size( $leaves ); $j += 2) { if ($leaves[$j+1] == "rigidBody") { rigidBody -e $cmdString $selObj[$i]; string $fmt = (uiRes("m_makeRigidActive.kRigidBodyEditInfo")); print( `format -s $cmdString -s $selObj[$i] $fmt` ); $isRigid = 1; break; } } if ( !$isRigid ) { string $rigidName; string $fmt = (uiRes("m_makeRigidActive.kRigidBodyInfo")); print( `format -s $cmdString -s $selObj[$i] $fmt` ); $rigidName = `rigidBody $cmdString $selObj[$i]`; if ( $rigidName != "" ) { $isRigid = 1; } } } return $isRigid; }