// =========================================================================== // 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: July 30, 1997 // // // // // // // deleteAllContainers // // // int $selectedOnly // // // None // // // Deletes all containers (or all selected containers) in the scene // other than those that are locked or in referenced files. The // contents of the container will remain in the scene. // // // None // // // // To delete all containers // deleteAllContainers; // // // ///////////////////////////////////////////////////////////////////////// global proc deleteAllContainers(int $selectedOnly) { int $count = 0; string $allContainers[]; if ($selectedOnly) { $allContainers = `ls -sl -containers`; } else { $allContainers = `ls -containers`; } for ($container in $allContainers) { if (`objectType -isa "transform" $container`) { // remove descendents so that deleting the container // doesn't automatically delete the children // ungroup $container; } } int $skipped = 0; for ($container in $allContainers) { if (! `objExists $container`) { continue; } // do not delete it if it's from a referenced file string $readOnly[] = `ls -readOnly $container`; if (size($readOnly) == 0) { // do not delete it if it's locked int $isLocked[] = `lockNode -q $container`; if (0 == $isLocked[0]) { container -e -removeContainer $container; $count++; } else { $skipped++; } } else { $skipped++; } } if ($count == 0) { if ($skipped > 0) { error( (uiRes("m_deleteAllContainers.kContainersLockedOrReferenced"))); } else { print( (uiRes("m_deleteAllContainers.kNoContainersToDelete")) ); } } else { string $deleteContainers = (uiRes("m_deleteAllContainers.kDeletedContainers")); string $info = `format -stringArg $count $deleteContainers`; print( $info ); } }