python, scripts, softimage

deleteEmptyPartitions


I like to keep my passes tidy so this little script just strips out any empty partitions on selected passes.

#  USE: Select passes and run the script

import win32com

xsi = Application

selectedPasses = win32com.client.Dispatch( "XSI.Collection" )
selectedPasses.AddItems (xsi.Selection)

#--------------------------------------------------------------
#--------------------------------------------------------------
#--------------------------------------------------------------

def stripPass(eachPass):
	partitionsColl = win32com.client.Dispatch( "XSI.Collection" )
	for eachPartition in eachPass.Partitions:
		partitionsColl.AddItems (eachPartition)
	
       #-- Remove background partitions from the collection ---------------------
	partitionsColl.RemoveItems (partitionsColl[0])
	partitionsColl.RemoveItems (partitionsColl[0])
	
	for eachPartition in partitionsColl:
		if eachPartition.Members.Count == 0:
			print str(eachPartition) + " is empty :: Deleted ::"
			xsi.DeleteObj (eachPartition)

#--------------------------------------------------------------
#--------------------------------------------------------------


for eachPass in selectedPasses:
	stripPass(eachPass)
	

Leave a Reply

Your email address will not be published. Required fields are marked *

3 × 2 =