Notifications
Clear all

[Closed] How to clear rendered frame window ?

Hello everyone !

I’m rendering multiple frames with maxscript, and I use #regionselected option.

First frame renders just fine, but I would need to clear the rendered frame window before rendering the next frame. Same function as the X-button in a rendered frame window, but accessible with maxscript.

Disabling the rendered frame window makes no difference. Any hints ?

I’m using max2008 and Vray 1.5RC2.

Best regards,
Jukka

7 Replies

If you know the region you’ve rendered, just save that part…


    fn SaveRenderedRegion SaveFilename Region DisplayBitmap:False =
    (
    local BitWidth = ( Region[3] - Region[1] )
    local BitHeight = ( Region[4] - Region[2] )
    local RendBitmap = getLastRenderedImage()
    local TempBitmap = bitmap  BitWidth BitHeight
    local tnScanLine
    
    for y = 0 to (BitHeight-1) do
    	(
    	tnScanLine = getPixels RendBitmap [Region[1],(Region[2]+y)] BitWidth
    	setPixels TempBitmap [0,y] tnScanLine
    	)
    
    TempBitmap.filename = SaveFilename
    save TempBitmap
 if DisplayBitmap then
 	display TempBitmap	
    )

Usage

SaveRenderedRegion "C:\	emp\\Wow.jpg" [200,200,400,400]
SaveRenderedRegion "C:\	emp\\Wow.jpg" [100,100,300,300] DisplayBitmap:true

I think VRay may have a function to clear its VFB, but you’d have to check with them.

To clear the 3ds Max VFB, you can try the following function:


fn resetVFB = (
	if ((maxVersion())[1] < 9000) then ( return -1 )
	myDialogs = UIAccessor.getChildWindows 0
	maxVFB = undefined
	for dlg in myDialogs do (
		dialogTitle = UIAccessor.getWindowText dlg
		if (matchpattern dialogTitle pattern:"*, frame * (*:*)") then (
			maxVFB = dlg
			exit
		)
	)
	if (maxVFB == undefined) then ( return -2 )
	VFB_ResetButton = undefined
	VFB_children = UIAccessor.getChildWindows maxVFB
	for VFB_child in VFB_children do (
		if (uiaccessor.getWindowResourceID VFB_child == 260) then (
			VFB_ResetButton = VFB_child
			exit
		)
	)
	if (VFB_ResetButton == undefined) then ( return -3 )
	UIAccessor.pressButton VFB_ResetButton
	OK
)

Quick run-down of the code…

  • It gets all top-level windows, which includes any VFBs
  • then checks if the window’s title matches that of a typical VFB
  • if it does, it looks for the reset button (by control ID 260, as the index will vary per max version, but the ID shouldn’t, and doesn’t from R9-R2009 at least)
  • finally, presses that button.

There’s one quite obvious caveat: if you have more than one VFB, it will press the reset button on whichever it finds first. There’s a few ways around this, but none are particularly pretty

Thank you very much for this great piece of code ! It was a great releaf to get this thing working with my rendering script, now it’s possible to use regionselected easily again!

I was able to use script as you pasted it above with Max2008 32-bit.

With Max2008 64-bit it needs some updating. One thing I was able to debug was to change:

if (matchpattern dialogTitle pattern:"*, frame * (*:*)") then (

->

if (matchpattern (dialogTitle as string) pattern:"*, frame * (*:*)") then (

The other thing is that I can’t get the control ID of the X-button (ID 260 in max2008-32bit). I was able to get the following list of different ID’s on the rendered frame window:

resourceID: 0
  resourceID: 0
  resourceID: 70257
  resourceID: 0
  resourceID: 261
  resourceID: 0
  resourceID: 355
  resourceID: 0
  resourceID: 267
  resourceID: 0
  resourceID: 70258
  resourceID: 0
  resourceID: 256
  resourceID: 0
  resourceID: 257
  resourceID: 0
  resourceID: 258
  resourceID: 0

I tried each one of them, and was able to access all the other buttons in the window, but not the “clear window”-button. :hmm:

Any ideas ?

that ‘as string’ is perplexing, as that should already be a string; but whatever works

the other part… rut roh.

You could mess around with some MaxScript code (windows struct and such), but if you want a shortcut – download WinSpy++, run that, then drag the crosshairs over the reset button of the VFB – it should tell you what control ID it is (I believe it gives you a hex value, so make sure you specify it as such, or calculate the decimal value from it).

The following should be the correct URL:
http://www.catch22.net/software/winspy.asp

Thanks for the tip (again)

I was able to find out, that control ID is the same in Max2008 32-bit and in Max2008 64-bit, 260 is it as decimal.

I did make the button work, after setting the caption for the clear-button in WinSpy++. After that this works just fine:

UIAccessor.PressButtonByName VFB_child "Clear"

So it goes down to lazy people at Autodesk, not setting button captions to make our life easier Caption is still missing from Max2009…

So max2008 32-bit and max2009 64-bit in Windows Vista business 64-bit are the only enviroments that it works… no success with Windows XP SP2 32bit with Max2008 32-bit either

Well… have to render with 2009 then…

well, lack of captions is annoying, but you don’t really need .pressButtonByName; Once you’ve identified the correct control ID, you can get the correct control hwnd and then just use ‘.pressButton <hwnd>’, as per the earlier script’s second half