// =========================================================================== // 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. // =========================================================================== // // proc int dynSettingsInList(string $list[], string $name) // // Return whether $name is in $list. // { int $inList = 0; for ($i = 0; $i < size($list); $i++) { if ($name == $list[$i]) { $inList = 1; break; } } return $inList; } global proc cacheDelete() // // Deletes the cache for all the selected dynamic objects. { string $selectedParticles[] = `ls -sl -type particle`; string $selectedRigidBodies[] = `ls -sl -type rigidBody`; string $selectedTransforms[] = `ls -sl -transforms`; for ($i = 0; $i < size($selectedTransforms); $i++) { string $kidShapes[] = `listRelatives -s $selectedTransforms[$i]`; string $particleKids[] = `ls -type particle $kidShapes`; int $count = size($selectedParticles); for ($j = 0; $j < size($particleKids); $j++) { if (!dynSettingsInList($selectedParticles, $particleKids[$j])) { $selectedParticles[$count] = $particleKids[$j]; $count++; } } } for ($i = 0; $i < size($selectedTransforms); $i++) { string $kidShapes[] = `listRelatives -s $selectedTransforms[$i]`; string $rigidBodyKids[] = `ls -type rigidBody $kidShapes`; int $count = size($selectedRigidBodies); for ($j = 0; $j < size($rigidBodyKids); $j++) { if (!dynSettingsInList($selectedRigidBodies, $rigidBodyKids[$j])) { $selectedRigidBodies[$count] = $rigidBodyKids[$j]; $count++; } } } string $cmd; string $names; string $printMsg = (uiRes("m_cacheDelete.kResultCacheDelete")) ; int $particleCount = size($selectedParticles); for ($i = 0; $i < $particleCount; $i++) { $names = $names + " " + $selectedParticles[$i]; $cmd = "particle -e -deleteCache " + $selectedParticles[$i]; evalEcho $cmd; } if ($particleCount > 0) { print `format -stringArg $names $printMsg` ; } $names = ""; int $rigidBodyCount = size($selectedRigidBodies); for ($i = 0; $i < $rigidBodyCount; $i++) { $names = $names + " " + $selectedRigidBodies[$i]; $cmd = "rigidBody -e -deleteCache " + $selectedRigidBodies[$i]; evalEcho $cmd; } if ($rigidBodyCount > 0) { print `format -stringArg $names $printMsg` ; } }