Page 1 of 4

BlendLuxCore: Save image while render is paused

Posted: Mon Apr 06, 2020 6:21 pm
by Sharlybg
BYOB please can you help me ? I want to know if blender api allow to save a render while being in pause ?

Re: BlendLuxCore Development

Posted: Mon Apr 06, 2020 6:32 pm
by B.Y.O.B.
Blender API probably not, but LuxCore allows it.
However, it will lack Blender's color management (filmic etc.) and compositing.

Re: BlendLuxCore Development

Posted: Mon Apr 06, 2020 6:50 pm
by Sharlybg
B.Y.O.B. wrote: Mon Apr 06, 2020 6:32 pm Blender API probably not, but LuxCore allows it.
However, it will lack Blender's color management (filmic etc.) and compositing.
You mean image will be saved as Exr. So we can just reload them automatically and save to jpg so they get the ajustment applied.

But anyway step by step. Can we have the first stage of save while rendering.

Re: BlendLuxCore Development

Posted: Mon Apr 06, 2020 7:06 pm
by B.Y.O.B.
Sharlybg wrote: Mon Apr 06, 2020 6:50 pm But anyway step by step. Can we have the first stage of save while rendering.
After this line, you can insert

Code: Select all

engine.session.GetFilm().SaveOutputs()
This will save the outputs to your BlendLuxCore installation directory every time you pause the render.

Re: BlendLuxCore: Save image while render is paused

Posted: Mon Apr 06, 2020 7:13 pm
by Sharlybg
Thank you so much :D

What if i want it to be the blendfile folder to be the automatic output ? :mrgreen:

I hope the file will not be rewrite each time i hit pause. So i can keep each image file.

Re: BlendLuxCore: Save image while render is paused

Posted: Mon Apr 06, 2020 7:23 pm
by B.Y.O.B.
Sharlybg wrote: Mon Apr 06, 2020 7:13 pm What if i want it to be the blendfile folder to be the automatic output ?
I'm not sure if the LuxCore API offers a way to pass a filepath to SaveOutputs(), this is a question for Dade.
Sharlybg wrote: Mon Apr 06, 2020 7:13 pm I hope the file will not be rewrite each time i hit pause. So i can keep each image file.
You have to rename the images or move them somewhere else if you want to prevent them from being overwritten.

Re: BlendLuxCore: Save image while render is paused

Posted: Mon Apr 06, 2020 7:37 pm
by alpistinho
You have to rename the images or move them somewhere else if you want to prevent them from being overwritten.
I guess you could probably do something like:

Code: Select all

import os
from datetime import datetime
os.rename('a.exr', '{}.exr'.format(datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
Just change a.exr to the name Luxcore saves the file.
You may also want to put the absolute path instead of the relative

Re: BlendLuxCore: Save image while render is paused

Posted: Mon Apr 06, 2020 7:39 pm
by Dade
B.Y.O.B. wrote: Mon Apr 06, 2020 7:23 pm
Sharlybg wrote: Mon Apr 06, 2020 7:13 pm What if i want it to be the blendfile folder to be the automatic output ?
I'm not sure if the LuxCore API offers a way to pass a filepath to SaveOutputs(), this is a question for Dade.
There is the "SaveOutput()" for that but Alpistinho's solution is simpler.

Re: BlendLuxCore: Save image while render is paused

Posted: Mon Apr 06, 2020 7:45 pm
by Sharlybg
The first code line by BYOB seem to not give me any result. there is no file saved and i have to search in all folder as i don't know wich exact folder get the file. but a quick search "exr" inside addon folder show nothing.

Alpistinho can you upload you're working modified final.py file so i can overwritte mine and be sure instruction are the same ?

I'm a bit overhelming.

Re: BlendLuxCore: Save image while render is paused

Posted: Mon Apr 06, 2020 7:49 pm
by alpistinho
Sharlybg wrote: Mon Apr 06, 2020 7:45 pm The first code line by BYOB seem to not give me any result. there is no file saved and i have to search in all folder as i don't know wich exact folder get the file. but a quick search "exr" inside addon folder show nothing.

Alpistinho can you upload you're working modified final.py file so i can overwritte mine and be sure instruction are the same ?

I'm a bit overhelming.
I hadn't even seen the code before, but I came up with that:

Code: Select all

if LuxCoreDisplaySettings.paused:
            if not engine.session.IsInPause():
                engine.session.Pause()
                utils_render.update_status_msg(stats, engine, depsgraph.scene, config, time_until_film_refresh=0)
                engine.framebuffer.draw(engine, engine.session, depsgraph.scene, render_stopped=False)
                engine.update_stats("", "Paused")
                
                # Our crappy patch here 
                engine.session.GetFilm().SaveOutputs()
                import os
		from datetime import datetime
		os.rename('a.exr', '{}.exr'.format(datetime.now().strftime('%Y-%m-%d-%H-%M-%S')))