stop script when Rendering is cancel

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  06 June 2013
stop script when Rendering is cancel

Hello all,
when I use this script command in an loop:


vfb = render vfb:true progressbar:true [...] cancelled:&wasCancelled
 if (wasCancelled) do return false


It start the rendering and when I hit cancel the script stop. But how can I use this function when I want to use the:

max quick render

command?
 
  06 June 2013
Now I test, if the last render file exist:


 if (rendTimeType == 1) then (
	if (openBitMap (outF + "_" + ddlType.items[ddlType.selection]) == undefined) do return false
	) else if (rendTimeType == 2) then (
	num1 = l - 1 + animationRange.start
	num2 = "000" + num1 as string 
	num3 = subString num2 (num2.count - 3) 4
	
	if (openBitMap (outF + "_"+ num3 + ddlType.items[ddlType.selection]) == undefined) do return false
	) else if (rendTimeType == 3) then (
		num1 = l - 1 + rendStart
		num2 = "000" + num1 as string 
		num3 = subString num2 (num2.count - 3) 4
		
		if (openBitMap (outF + "_"+ num3 + ddlType.items[ddlType.selection]) == undefined) do return false
		)

 


Maybe is not so error stable, but I think it works. What are you thinking? Other Ideas are also welcome!
 
  06 June 2013
if you know how many frames has to be rendered you can count every next rendered frame using #postRenderFrame general callback. and if the final number of rendered frames equals the desired number, the render was not canceled:
so it might be as:
callbacks.removescripts id:#cancel_render_check
global TotalFrames = 11
global RenderedFrames
callbacks.addscript #preRender "RenderedFrames = 0" id:#cancel_render_check
callbacks.addscript #postRenderFrame "RenderedFrames += 1" id:#cancel_render_check
callbacks.addscript #postRender "format \"render was canceled: %\n\" (RenderedFrames < TotalFrames)" id:#cancel_render_check

Last edited by denisT : 06 June 2013 at 06:06 PM.
 
  06 June 2013
here is a most correct version... hopefully i don't forget anything:
callbacks.removescripts id:#cancel_render_check
  
  fn getNumberRenderFrames = 
  (
  	case rendTimeType of 
  	(
  		1: 1
  		2: (animationrange.end - animationrange.start + 1)/rendNThFrame 
  		3: (rendEnd - rendStart + 1)/rendNThFrame
  		4:
  		(
  			ff = filterstring rendPickupFrames ","
  			num = 0
  			for f in ff do if (f as integer != undefined) then num += 1 else
  			(
  				vv = filterstring f "- "
  				num += vv[vv.count] as integer - vv[1] as integer + 1
  			)
  			num
  		 )
  	)
  )
  
  global TotalFrames
  global RenderedFrames
  
  callbacks.addscript #preRender "TotalFrames = getNumberRenderFrames(); RenderedFrames = 0" id:#cancel_render_check
  callbacks.addscript #postRenderFrame "RenderedFrames += 1; print currenttime" id:#cancel_render_check
  callbacks.addscript #postRender "format \"render was canceled: %\n\" (RenderedFrames < TotalFrames)" id:#cancel_render_check

Last edited by denisT : 06 June 2013 at 07:21 PM.
 
  06 June 2013
there is some rarely used format for rendPickupFrames - start<space>end... i've supported it as well...
just as a little test
try to guess what frames will be rendered with "1 10 4, 3" rendPickupFrames string?

Last edited by denisT : 06 June 2013 at 06:46 PM.
 
  06 June 2013
Thanks denisT for all that! I will try this tomorrow, then I can say how it works!

Have a nice evening!
 
  06 June 2013
Ok I think I am done, thanks again! When someone need the script:

https://github.com/jb-alvarado/Chan...extureAndRender

It was more for inhouse use, so maybe it have not all options.

edit: I don't know what's happen, but at the moment it doesn't work anymore. The callback function build errors.

edit2: I combine now your code with my.


  local num3=""
 	case rendTimeType of (
 		1: num3 = ""
 		2: (
 			num1 = l - 1 + animationRange.start + rendFileNumberBase
 			num2 = "000" + num1 as string 
 			num3 = subString num2 (num2.count - 3) 4
 			)
 		3: (
 			num1 = l - 1 + rendStart + rendFileNumberBase 
 			num2 = "000" + num1 as string 
 			num3 = subString num2 (num2.count - 3) 4
 			)
 		4: (
 			num1 = filterstring rendPickupFrames ",- "
 			num2 = "000" + num1[num1.count]
 			num3 = subString num2 (num2.count - 3) 4
 			)
 	)
 
 if (openBitMap (outF + "_"+ num3 + ddlType.items[ddlType.selection]) == undefined) do return false
 
  

Last edited by jb-alvarado : 06 June 2013 at 03:42 PM.
 
  06 June 2013
Originally Posted by jb-alvarado: Ok I think I am done, thanks again! When someone need the script:

https://github.com/jb-alvarado/Chan...extureAndRender

It was more for inhouse use, so maybe it have not all options.

edit: I don't know what's happen, but at the moment it doesn't work anymore. The callback function build errors.


you have to setup all callbacks BEFORE(!) you call max quick render
 
  06 June 2013

...
callbacks.addscript #preRender "TotalFrames = getNumberRenderFrames(); RenderedFrames = 0" id:#cancel_render_check
callbacks.addscript #postRenderFrame "RenderedFrames += 1;" id:#cancel_render_check
callbacks.addscript #postRender "(RenderedFrames < TotalFrames)" id:#cancel_render_check

max quick render
...
 
  06 June 2013
I never work with them before and in general this is my 4. script. But yes now when you say this, it makes sense. Strange that it was working before I close max one time. Thanks!
 
  06 June 2013
Originally Posted by jb-alvarado: I never work with them before and in general this is my 4. script. But yes now when you say this, it makes sense. Strange that it was working before I close max one time. Thanks!

it will be better to remove all callback scripts after quick render was finished

 ...
 max quick render
 callbacks.removescripts id:#cancel_render_check
...
 
 
  06 June 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 11:21 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.