// =========================================================================== // 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: 2001 // // // // // // // deleteUnusedBrushes // // // None. // // // This deletes all brushes that are not attached to any strokes // This can be used to clean up default brush nodes that may accumulate // when doing a large number of import operations. // // // None. // // // deleteUnusedBrushes; // // global proc int deleteUnusedBrushes() { // 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(); int $i; string $brushes[] = `ls -type brush`; string $defaultBrush = getDefaultBrush(); if( $showProgress ) { cleanUp_StartProgress( size($brushes), "Deleting unused brushes", 1 ); } int $numDeleted = 0; for( $i = 0; $i < size( $brushes ); $i++ ) { if( $showProgress ) { if( cleanUp_SetProgress($i) ) break; } if( $brushes[$i] != $defaultBrush ){ string $con[] = `listConnections ($brushes[$i]+".outBrush")`; if( size( $con ) == 0 ){ if ( `reference -q -isNodeReferenced $brushes[$i]`) { warning( (uiRes("m_deleteUnusedBrushes.kCantDeleteUnusedBrush"))); } else { string $cmd = "delete " + $brushes[$i]; evalEcho($cmd); $numDeleted++; } } } } if( $showProgress ) { cleanUp_EndProgress(); } return $numDeleted; }