// =========================================================================== // 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: June 2002 // // Description: // Delete unused animation poses or clips from the scene. // Arguments: // $typeToDelete (string): valid values are: "clips" or "poses" // ///////////////////////////////////////////////////////////////////////// global proc int deleteUnusedTrax(string $typeToDelete ) { // Are we being called during an Optimize Scene Size operation? // If so, we need to display progress information. This was done // as a global variable to avoid having to change the signature of // the proc, as that could break many scripts, both internal and // customer-written. // int $showProgress = cleanUp_ShouldReportProgress(); if ($typeToDelete != "poses" && $typeToDelete != "clips") { error( (uiRes("m_deleteUnusedTrax.kInvalidArgument")) ); return 0; } // we store them up and don't delete them using a single delete command // since deleting one might cause others to get deleted and the loop // would get messed up // string $nodesToDelete; string $clips[]; string $allClips[]; if ($typeToDelete == "clips") { $clips = `clip -q -allSourceClips`; $allClips = `clip -q -allClips`; } else { $clips = `pose -q -allPoses`; } if( $showProgress ) { cleanUp_StartProgress( size($clips)+size($allClips), ("Deleting unused " + $typeToDelete), 1 ); } int $numDeleted = 0; int $i = 0; for ($clip in $clips) { if( $showProgress ) { if( cleanUp_SetProgress($i++) ) break; } int $deleteIt = 1; string $chs[] = `clip -q -character $clip`; for ($ch in $chs) { string $sched = `character -q -sc $ch`; int $clipIndexList[] = `clipSchedule -n $clip -q -ci $sched`; if (size($clipIndexList) > 0) { $deleteIt = 0; } } if ($deleteIt) { $nodesToDelete += ($clip+" "); $numDeleted++; } } for ($clip in $allClips) { string $conns[] = `listConnections $clip`; if (size($conns) == 0) { $nodesToDelete += ($clip+" "); $numDeleted++; } } if (size($nodesToDelete)) { $cmd = ("delete "+$nodesToDelete); evalEcho($cmd); } if( $showProgress ) { cleanUp_EndProgress(); } return $numDeleted; }