''  This file downloaded from www.EdHarriss.com
''  
''  www.EdHarriss.com File Information:
''  
''    Script Name: LM_RenderSelectedPasses.vbs v0.0
''    Author: Ludovick William Michaud
''    Update/Change this file at by sending e-mail to EdHarriss@EdHarriss.com
''

'******************************************************************************
'
' File supervisor : Ludovick William Michaud
' Date : November 06 2001
' (c) Copyright 2001 Janimatiom
'
' @doc
'
' $Archive: $
' $Revision: $  $Date: November 06 2001
' Checkin by: $Author: Ludovick William Michaud
'
' @module	LM_RenderSelectedPasses.vbs
'
'******************************************************************************
'//General Script Render Selected Passes by the user only.
RenderSelPass

function RenderSelPass
	'//This is the line to actually bypass the fact that you cancel the Operation
	On Error Resume Next

	set oCurSel = GetValue("SelectionList")

	for i = 0 to oCurSel.count - 1
		if oCurSel(i).type <> "#Pass" then
			RemoveFromSelection oCurSel(i).FullName
		end if
	next 
	set oCurSel = GetValue("SelectionList")
	
	if oCurSel <> "" then
		On Error Resume Next
		if oCurSel(0).type = "#Pass" then
			set oPassList = GetValue("SelectionList")
			for i=0 to oPassList.count - 1
				if oPassList(i).type = "#Pass" then
					RenderPass oPassList(i).FullName
					logmessage "The Pass " & oPassList(i).FullName & " was selected and rendered."
				end if
			next
			exit function
		end if
	else
		'//In case the user Change the name of the Scene Root
		'//Find the Scene_Root object 
			set mySceneRoot = EnumElements("Project", TRUE)
			set mySceneRoot = SIFilter(mySceneRoot, "Scene", TRUE )(0)
			set mySceneRoot = EnumElements( mySceneRoot , TRUE)
			set mySceneRoot = SIFilter(mySceneRoot, "SceneObject", TRUE)(0)
		
		'//First let's find out what is the name of the scene and put it under a collection item
			set oProj = ActiveProject '//l_Proj.ActiveScene.name
			set PassesRender = AddProp ("Custom_parameter_list",mySceneRoot, , "Passes Selection").Value("Value")
			set oPassList = GetValue("Passes.List")
	
			for each lPasses in oPassList
				SIAddCustomParameter PassesRender, lPasses.Name, siBool, 1, , , , 0 
			next		
	
			InspectObj mySceneRoot & "." & PassesRender,,"Render Selected Passes",siModal
			if Err.Number = 0 then
			for i=0 to oPassList.count - 1
				if GetValue(PassesRender & "." & oPassList(i).name ) <> 0 then
					RenderPass oPassList(i).FullName
					logmessage "The Pass " & oPassList(i).FullName & " was selected and rendered."
				end if
			next
			end if

		DeleteObj mySceneRoot & "." & PassesRender
	end if
end Function
