ScriptSpot

Forum topic · Scripts Wanted

How do I get the progress information of the rendering?

By Encoding · 2018-07-17

Description

I now have a separate thread that needs to read the progress information of the rendering in real time, and how can I predict it?

Attachments
Comments (5)

LilyWitt · 2020-01-31

You explore some little rumors to get more knowledge of progress then after you will get the vast number of information. People who made you want to bestessays and suggestions to do this that type of projecting.

Encoding · 2018-07-24

I need to read the current rendering progress during rendering and save it as a txt document. Is there any way to read the rendering progress information?

.

jahman · 2018-07-24

I bet there's a better way of doing it. But here's the example how you can achieve it using BackgroundWorker and DialogMonitorOps


gc light:true
try (
	::renderProgressTimer.Stop() 
	dotNet.removeAllEventHandlers ::renderProgressTimer
)catch()

global renderingDialogHWND = undefined
global renderProgressTimer = dotnetobject "System.Windows.Forms.Timer"
renderProgressTimer.interval = 2000 -- two seconds

fn onTick sender arg = 
(	
	if isKindOf ::renderingDialogHWND IntegerPtr do 
	(
		local data = windows.getHWNDData ::renderingDialogHWND

		if data == undefined then
		(
			format "Timer is stopping..\n" 
			sender.Stop()
			
			DialogMonitorOPS.enabled = false
			DialogMonitorOPS.UnRegisterNotification id:#renderProgress
		)
	)
	
)
dotnet.addEventHandler renderProgressTimer "Tick" onTick 


bw = dotNetObject "CSharpUtilities.SynchronizingBackgroundWorker"
fn dowork =
(
	format "Background worker started\n" 
	local t = timeStamp()
		
	while ::renderProgressTimer.enabled do
	(
		if timeStamp() - t >= ::renderProgressTimer.interval do
		(
			t = timeStamp()
			
			local data = windows.getHWNDData ::renderingDialogHWND
			
			if data != undefined do
			(				
				for c in windows.getChildrenHWND ::renderingDialogHWND where c[4] == "Static" do 
				(
					if MatchPattern c[5] pattern:"Rendering*pass*" do format "!>> %\n" c[5]			
					
				)
			)
		)
	)
	
	format "Background worker completed\n" 
	
)
dotnet.addEventHandler bw "DoWork" dowork


fn onWindow =
(
	local hwnd = DialogMonitorOPS.GetWindowHandle()
	
	if hwnd != undefined do
	(
		local data = windows.getHWNDData hwnd
		
		if data[4] == "#32770" and data[5] == "Rendering" do
		(
			format "Rendering...\n" 
			if isKindOf ::renderProgressTimer dotNetObject do 
			(
				format "Starting timer\n" 
				::renderingDialogHWND = data[1]
				::renderProgressTimer.start()
				
				::bw.runWorkerAsync()
				
			)
			
		)
		
	)
	
	true
)

DialogMonitorOPS.UnRegisterNotification id:#renderProgress
DialogMonitorOPS.RegisterNotification onWindow id:#renderProgress
DialogMonitorOPS.enabled = true

clearListener()

Encoding · 2018-07-25

Thank you very much for your help, this method has solved my problem. When I have other better methods, I will send it here to study together.

^

TsveTan · 2018-07-21

What is the rendering engine and how did you create this thread?