This little script has been written in both VBScript and recently converted to Python in order to get acquainted with the language.

Having worked on a project that uses hundreds of passes which contain a similar number of partitions I felt a simple little script that would move the selected objects/lights into the background partitions in either the current pass or multiple selected passes would make the process of hiding off objects a lot lot easier.

Python

# Move selected objects to background partitions
 
# created by Gareth Bell
 
# original created in VBScript 28-11-11
# converted to Python 26-07-2012
 
 
# Description:
# This script will put the selected objects into either the current passes bg partitions or, if selected, multiple passes bg partitions
 
##################################
 
# To use:  select objects and passes. Run.
 
##################################
 
import win32com
xsi = Application
 
#create collections to store objects
geoColl = win32com.client.Dispatch( "XSI.Collection" )
passesColl = win32com.client.Dispatch( "XSI.Collection" )
lightsColl = win32com.client.Dispatch( "XSI.Collection" )
 
selection = win32com.client.Dispatch( "XSI.Collection" )
selection.AddItems (xsi.Selection)
 
#sort selection into collections (objects, lights and passes)
for obj in selection:
          if obj.type == "light":
                   lightsColl.AddItems (obj)
          elif obj.type == "Pass":
                   passesColl.AddItems (obj)
          else:
                   geoColl.AddItems (obj)
                  
passCount = passesColl.Count
 
#decide if sorting is in only the current pass or multiple passes
if passCount > 0:
          for eachPass in passesColl:     
			print str(geoColl) + " has/have been put into the background partition in " + str(eachPass.name)
			xsi.MoveToPartition(str(eachPass) + ".background_objects_partition", geoColl, eachPass)
			print str(lightsColl) + " has/have been put into the background partition in " + str(eachPass.name)
			xsi.MoveToPartition(str(eachPass) + ".background_lights_partition", lightsColl, eachPass)
else:
	currentPass = xsi.ActiveProject.ActiveScene.ActivePass
	print str(geoColl) + " has/have been put into the background partition in the current pass"
	xsi.MoveToPartition(str(currentPass) + ".background_objects_partition", geoColl, currentPass)               
	print str(lightsColl) + " has/have been put into the background partition in the current pass"
	xsi.MoveToPartition(str(currentPass) + ".background_lights_partition", lightsColl, currentPass)    
				   
				   

VBScript

' Move selected objects to background partitions
' created by Gareth Bell
 
' 28-11-11
 
' Description:
'  This script will put the selected objects into either the current passes bg partitions or, if selected, multiple passes bg partitions
 
'#################################
 
' To use:  select objects and passes. Run.
 
'#################################
 
set oGeometry = CreateObject ("XSI.Collection")
set oPasses = CreateObject ("XSI.Collection")
set oLights = CreateObject ("XSI.Collection")
 
set oSelection = CreateObject ("XSI.Collection")
oSelection.AddItems Selection
 
for each oObj in oSelection
          if oObj.type = "light" then
                   oLights.AddItems oObj
          else    if oObj.type = "Pass" then
                   oPasses.AddItems oObj      
          else
                   oGeometry.AddItems oObj
          end if
          end if
next
 
passesCount = oPasses.count
 
if passesCount > 0 then
          for each oPass in oPasses
                   for each oGeo in oGeometry
                   logmessage oGeo & " has been put into the background partition in " & oPass.name
                   MoveToPartition  oPass & ".background_objects_partition", oGeo, oPass
                   next
                  
                   for each oLight in oLights    
                   logmessage oLight & " has been put into the background lights partition in " & oPass.name
                   MoveToPartition  oPass & ".background_lights_partition", oLight, oPass
                   next
          next
 
else
          oCurrentPass = Application.ActiveProject.ActiveScene.ActivePass
          for each oGeo in oGeometry
                   logmessage oGeo & " has been put into the background partition"
                   MoveToPartition  oCurrentPass & ".background_objects_partition", oGeo, oCurrentPass
          next
         
          for each oLight in oLights    
                   logmessage oLight & " has been put into the background lights partition"
                   MoveToPartition  oCurrentPass & ".background_lights_partition", oLight, oCurrentPass
          next
 
end if