# ns_BruteForceVrayRender
# Initial code generated by Softimage SDK Wizard
# Executed Thu Oct 24 10:43:06 UTC+0200 2013 by freelancer
# 
# Tip: To add a command to this plug-in, right-click in the 
# script editor and choose Tools > Add Command.
import win32com.client
from win32com.client import constants

null = None
false = 0
true = 1

def XSILoadPlugin( in_reg ):
	in_reg.Author = "Niclas Schlapmann"
	in_reg.Name = "ns_VrayRenderBruteForce"
	in_reg.Major = 1
	in_reg.Minor = 0
	
	in_reg.RegisterCommand("ns_VrayRenderBruteForce","ns_VrayRenderBruteForce")
	in_reg.RegisterMenu(constants.siMenuTbRenderRenderID, "ns_VrayRenderBruteForce_Menu", False, False)


	#RegistrationInsertionPoint - do not remove this line

	return true

def XSIUnloadPlugin( in_reg ):
	strPluginName = in_reg.Name
	Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
	return true
	
	
def ns_VrayRenderBruteForce_Execute(  ):
	try:
		begin = int(Application.XSIInputBox("Render Frame Start?", "Frame Start"))
		end = int(Application.XSIInputBox("Render Frame End?", "Frame End")) + 1
		Application.SetValue(str(Application.GetCurrentPass())+".VRay_Options.out_use_vrayvfb", False, "")

		while begin != end:
			Application.SetValue("PlayControl.Key", begin, "")
			Application.RenderPasses(str(Application.GetCurrentPass()), begin, begin, 1, "siRenderVerbosityDefault")
			begin = begin + 1
			Application.ClearVRayGeometryCache()
			Application.SetValue("PlayControl.Key", 1, "")
		
		Application.SetValue(str(Application.GetCurrentPass())+".VRay_Options.out_use_vrayvfb", True, "")
	except:
		pass
			
	return true
	
def ns_VrayRenderBruteForce_Menu_Init( in_ctxt ):
	oMenu = in_ctxt.Source
	oMenu.AddCommandItem("ns_VrayRenderBruteForce","ns_VrayRenderBruteForce")
	return true

	

