Notifications
Clear all

[Closed] How to clear last image?

I am ready to using scrpit to control rendering image,but I don’t know how to clean the last image that rendered,when I select region area render,that would appear this problem,so is there a command to clean (remove?) the last image ?

14 Replies
 lo1

this works

last = getLastRenderedImage copy:on
empty = bitmap last.Width last.Height color:(color 0 0 0 0)
pasteBitmap empty last [0,0] [0,0]
close empty
free empty

1 Reply
(@momo2012)
Joined: 11 months ago

Posts: 0

Hi lo,I tried,the empty is a read-only variable,I changed to empty1,but it seemed did not work,the LastRenderedImage still there ,no refreshed or cleared.

In fact,I want to clear here(see below) when I use “max quick render” code to render images one by one,so if the last one does not cleared,the current one will cause problem with region render.
I think it’s different from getLastRenderedImage,whatever how I change the last image with getLastRenderedImage,the “max quick render” one still there…

 lo1

You’re right about the ‘empty’ variable, but once you change that, it does work. The thing is that if the VFB is already open when you run this code it will not automatically refresh.
However, you can see that it is cleared by doing something such as resizing the VFB, changing the color channel of the VFB, or starting a new render.
If you need to refresh it programmatically, you can try using windows messages to refresh the VFB window.

2 Replies
(@momo2012)
Joined: 11 months ago

Posts: 0

I just tried ,add the code to render loop,failed.maybe need to refresh VFB window,but how?

(@momo2012)
Joined: 11 months ago

Posts: 0

Almost there,finally I found some codes :

for w in uiaccessor.getPopupDialogs() do
 (
    local firstChild = uiaccessor.getFirstChildWindow w
    if (uiaccessor.getWindowClassName firstChild) == "BitmapWindow" do
   (			
   windows.sendMessage firstChild 0x5 0 0 --WM_SIZE
   windows.sendMessage firstChild 0xf 0 0 --WM_PAINT
    )
  )

I don’t understand what’s mean,and these do not work ,I think change it would clear the vfb window:

windows.sendMessage firstChild 0x5 0 0 --WM_SIZE
   windows.sendMessage firstChild 0xf 0 0 --WM_PAINT

Anyone help?

 lo1

This would refresh the vfb after you’ve zeroed out the actual bitmap data, otherwise it would just show the same bitmap.

1 Reply
(@momo2012)
Joined: 11 months ago

Posts: 0

So it should refresh vfb window,but why it does not work after I run the codes? 🙁

 lo1

You haven’t posted any code so it’s hard to say.

1 Reply
(@momo2012)
Joined: 11 months ago

Posts: 0

 for w in uiaccessor.getPopupDialogs() 
do  
( 
    local firstChild = uiaccessor.getFirstChildWindow w     if 
(uiaccessor.getWindowClassName firstChild) == "BitmapWindow" do    
(			    
windows.sendMessage firstChild 0x5 0 0 --WM_SIZE 
   windows.sendMessage firstChild 0xf 0 0 --WM_PAINT     
)
)

Many thanks, lo,I mean these codes,I think should clear the VFB

 lo1

As I said before, this would only refresh the vfb after you’ve zeroed out the actual bitmap data, for example, using the code I initially posted, otherwise it would just show the same bitmap.

1 Reply
(@momo2012)
Joined: 11 months ago

Posts: 0

I see,I’ll try,thanks again.

 lo1

depending on your version of 3dsmax, you may need to use

getLastRenderedImage copy:off

instead of

getLastRenderedImage copy:on

We actually don’t want a copy, we want a reference to the actual live reference of the buffer image, but in older versions of max this parameter was mistakenly inverted – specifying on would get the live reference and off would make a copy. In newer versions it seems to have been fixed.

Here’s a complete working snippet:


last = getLastRenderedImage copy:off
empty1 = bitmap last.Width last.Height color:(color 0 0 0 0)
pasteBitmap empty1 last [0,0] [0,0]
close empty1
free empty1

for w in uiaccessor.getPopupDialogs() do 
(  
	local firstChild = uiaccessor.getFirstChildWindow w    
	if (uiaccessor.getWindowClassName firstChild) == "BitmapWindow" do  
	(			
		windows.sendMessage firstChild 0x5 0 0 --WM_SIZE    windows.sendMessage firstChild 0xf 0 0 --WM_PAINT     )   )
	)
)

Works perfect for 3dsmax,thanks lo.
After I test in V-ray vfb,I know its not same as 3dsmax,I tried to get the firstChild name of V-ray frame buffer window,but only “MXS_Scintilla” name returned ,so how to get the vfb name so I can continue?


  for w in uiaccessor.getPopupDialogs() do 
  (  
  	local firstChild = uiaccessor.getFirstChildWindow w 
  	print (uiaccessor.getWindowClassName firstChild)	
  	--if (uiaccessor.getWindowClassName firstChild) == "BitmapWindow" do  
  	--(			
  	--	windows.sendMessage firstChild 0x5 0 0 --WM_SIZE	windows.sendMessage firstChild 0xf 0 0 --WM_PAINT	 )   )
  	--)	
  )