How to get Vray Rendering statistics like CoronaRenderer.CoronaFp.getStatistic


#1

How to get Vray Rendering statistics? Just like CoronaRenderer.CoronaFp.getStatistic

or, get the Total time spent and Estimated remaining rendering time

Thanks

Refs:
https://docs.chaosgroup.com/display/VMAX/MAXScript
https://wiki.corona-renderer.com/maxscript


#2

If chaosgroup doesn’t provide any method to do this you could have simply parse it from the rendering window like that


#3

Good hack, :joy:, Thank you. @Serejah
now I can get values that are “Static” type.

By the way, Is it possible to get the value of the rendering progress bar?

I’d tried to use [Elapsed Time] and [Time Remaining] to calculate the percentage value of progressBar.
but I can’t get the [Time Remaining] when it shows like “??:??:??”


#4

Find a msctls_progress32 class control and use windows.sendmessage with PBM_GETPOS command to get the current value

t = dotNetObject "system.timers.timer"
t.interval = 1000

fn OnTick sender args =
( 
        -- most likely 'data[5] == "Rendering"' will only work for English max interface. Surely there is a better way to find this handle
	local hwnd = for w in UIAccessor.GetPopupDialogs() where (data = windows.getHWNDData w; data[5] == "Rendering") do exit with w
	
	if isKindOf hwnd IntegerPtr do
	(			
                -- There’re two msctls_progress32 controls in rendering dialog and the first is the one you need (not sure if it is valid for all max versions)	
		prog_hwnd = for w in windows.getChildrenHWND hwnd where w[4] == "msctls_progress32" do exit with w[1]
			
		if isKindOf prog_hwnd IntegerPtr do
		(
			progress = windows.sendMessage prog_hwnd (1024 + 8) 0 0
			
			format "Rendering progress: %\%\n" progress -- is it thread safe to print anything from a timer?
			
		)
	)
	
)

dotNet.addEventHandler t "Elapsed" OnTick
t.start()
max quick render
t.stop()
t.dispose()
gif


#5

Thank you @Serejah,

Spy so good! fuck win32!

my quick test:

-- https://forums.cgsociety.org/t/how-to-get-vray-rendering-statistics-like-coronarenderer-coronafp-getstatistic/2063613/4
(
	try(DestroyDialog RenderingStatistic)catch()

	global RenderingStatistic

	rollout RenderingStatistic "Rendering Statistic" Width:380 Height:80
	(
		progressBar pb "" pos:[0, 0] width:380 height:10 value:0 color:(color 68 191 189)
		label info "" offset:[15, 5] width:380 
		button btn "Render" offset:[0, 5] width:120 height:24

		local RenderingDialogHWND
		local CurrentTaskHWND
		local ProgressHWND
		local renderProgressTimer = dotnetobject "System.Windows.Forms.Timer"

		fn onTick sender arg = 
		(	
			if isKindOf RenderingDialogHWND IntegerPtr do 
			(
				local data = windows.getHWNDData RenderingDialogHWND
		 		
				if data != undefined then 
				(	
					CurrentTask = (windows.getHWNDData CurrentTaskHWND)[5]
					ProgressPos = windows.SendMessage ProgressHWND (1024 + 8) 0 0
					-- format "CurrentTask: % - ProgressPos: %\n" CurrentTask ProgressPos
					RenderingStatistic.info.text = "Current Task:  " + CurrentTask
					RenderingStatistic.pb.value = ProgressPos
				)
				else  
				(
					sender.stop()
					RenderingStatistic.info.text = "End of Rendering, have a good day!"
					RenderingStatistic.pb.value = 100
				)		
			)
		)

		fn getRenderingDialogHWND =
		(
			RenderingDialogHWND = undefined

			local hwnd = DialogMonitorOPS.GetWindowHandle()
			local windowsText = UIAccessor.GetWindowText hwnd

			if windowsText != undefined then
			(
				if matchpattern windowsText pattern:"Rendering -*" then
				(
					RenderingDialogHWND = hwnd
					
					local RollupWindowHWND  = for c in windows.getChildrenHWND RenderingDialogHWND where \
						c[4] == "RollupWindow" do exit with c[1]
					CurrentTaskHWND = UIAccessor.GetPrevWindow RollupWindowHWND

					ProgressHWND = for c in windows.getChildrenHWND RenderingDialogHWND where \
						c[4] == "msctls_progress32" do exit with c[1]

					format "% | % | % \n" RenderingDialogHWND CurrentTaskHWND ProgressHWND

					renderProgressTimer.start()

					DialogMonitorOPS.UnRegisterNotification id:#renderProgress
					DialogMonitorOPS.enabled = false
				)
			)
			true 
		)

		fn startRender = 
		(
			renderProgressTimer.interval = 20
			dotnet.addEventHandler renderProgressTimer "Tick" onTick 
			DialogMonitorOPS.enabled = true
			DialogMonitorOPS.RegisterNotification getRenderingDialogHWND id:#renderProgress  
			max quick render
		)

		on btn pressed do startRender()
	) 

	CreateDialog RenderingStatistic
)