CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 06-26-2013, 09:33 AM   #1
jb-alvarado
Veteran
 
jb-alvarado's Avatar
portfolio
Jonathan Baecker
Austria
 
Join Date: Apr 2006
Posts: 54
stop script when Rendering is cancel

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

Code:
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:
Code:
max quick render

command?
 
Old 06-26-2013, 04:03 PM   #2
jb-alvarado
Veteran
 
jb-alvarado's Avatar
portfolio
Jonathan Baecker
Austria
 
Join Date: Apr 2006
Posts: 54
Now I test, if the last render file exist:

Code:
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!
 
Old 06-26-2013, 06:01 PM   #3
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,328
Send a message via ICQ to denisT
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:
Code:
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-26-2013 at 06:06 PM.
 
Old 06-26-2013, 06:35 PM   #4
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,328
Send a message via ICQ to denisT
here is a most correct version... hopefully i don't forget anything:
Code:
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-26-2013 at 07:21 PM.
 
Old 06-26-2013, 06:43 PM   #5
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,328
Send a message via ICQ to denisT
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-26-2013 at 06:46 PM.
 
Old 06-26-2013, 08:11 PM   #6
jb-alvarado
Veteran
 
jb-alvarado's Avatar
portfolio
Jonathan Baecker
Austria
 
Join Date: Apr 2006
Posts: 54
Thanks denisT for all that! I will try this tomorrow, then I can say how it works!

Have a nice evening!
 
Old 06-27-2013, 02:12 PM   #7
jb-alvarado
Veteran
 
jb-alvarado's Avatar
portfolio
Jonathan Baecker
Austria
 
Join Date: Apr 2006
Posts: 54
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.

Code:
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-27-2013 at 03:42 PM.
 
Old 06-27-2013, 03:43 PM   #8
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,328
Send a message via ICQ to denisT
Quote:
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
 
Old 06-27-2013, 03:46 PM   #9
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,328
Send a message via ICQ to denisT
Code:
... 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 ...
 
Old 06-27-2013, 04:12 PM   #10
jb-alvarado
Veteran
 
jb-alvarado's Avatar
portfolio
Jonathan Baecker
Austria
 
Join Date: Apr 2006
Posts: 54
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!
 
Old 06-27-2013, 04:51 PM   #11
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,328
Send a message via ICQ to denisT
Quote:
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
Code:
... max quick render callbacks.removescripts id:#cancel_render_check ...
 
Old 06-27-2013, 04:51 PM   #12
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:45 AM.


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