[Closed] 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?
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!
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: %
\" (RenderedFrames < TotalFrames)" id:#cancel_render_check
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: %
\" (RenderedFrames < TotalFrames)" id:#cancel_render_check
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?
Thanks denisT for all that! I will try this tomorrow, then I can say how it works!
Have a nice evening!
Ok I think I am done, thanks again! When someone need the script:
[ https://github.com/jb-alvarado/ChangeColorTextureAndRender ]( https://github.com/jb-alvarado/ChangeColorTextureAndRender)
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
...
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
...
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
...