BlendLuxCore: Save image while render is paused

Discussion related to the LuxCore functionality, implementations and API.
User avatar
Sharlybg
Donor
Posts: 2009
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: BlendLuxCore: Save image while render is paused

Post by Sharlybg » Mon Apr 06, 2020 7:50 pm

This what i've done BYOB :

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")
                engine.session.GetFilm().SaveOutputs()
        else:
            if engine.session.IsInPause():
                engine.session.Resume()
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA

User avatar
Sharlybg
Donor
Posts: 2009
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: BlendLuxCore: Save image while render is paused

Post by Sharlybg » Mon Apr 06, 2020 8:00 pm

the code display isn't respect indentation but it is roughly the change
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA

CodeHD
Posts: 301
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: BlendLuxCore: Save image while render is paused

Post by CodeHD » Mon Apr 06, 2020 8:00 pm

after the line "import os", add the following command:

Code: Select all

                print(os.getcwd())
this will show you the directory where the file is saved in the Blender system console.

EDIT: for me on windows this is:

C:\Program Files\Blender Foundation\blender-2.81a-windows64

CodeHD
Posts: 301
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: BlendLuxCore: Save image while render is paused

Post by CodeHD » Mon Apr 06, 2020 8:09 pm

I've tested this, but Lux doesn't write an exr, only png, even when I set the output file type in the scene tab to exr :?:

CodeHD
Posts: 301
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: BlendLuxCore: Save image while render is paused

Post by CodeHD » Mon Apr 06, 2020 8:26 pm

here you go, this works for me:

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")
                import os
                from datetime import datetime
                from ..bin import pyluxcore
                dummypath = os.getcwd()
                dummyfile = os.path.join(dummypath, '{}.exr'.format(datetime.now().strftime('%Y-%m-%d-%H-%M-%S')))
                engine.session.GetFilm().SaveOutput(dummyfile, pyluxcore.FilmOutputType.RGB_IMAGEPIPELINE, pyluxcore.Properties())
        else:
            if engine.session.IsInPause():
                engine.session.Resume()

User avatar
B.Y.O.B.
Developer
Posts: 3555
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: BlendLuxCore: Save image while render is paused

Post by B.Y.O.B. » Mon Apr 06, 2020 8:27 pm

CodeHD wrote:
Mon Apr 06, 2020 8:00 pm
EDIT: for me on windows this is:

C:\Program Files\Blender Foundation\blender-2.81a-windows64
My bad, I had started Blender from the BlendLuxCore project directory on Linux, which is why the CWD (current working directory) was there for me.

Saving outputs does not work on Windows on my end because it tries to write to a directory where you need admin write permissions (i.e. the Blender installation folder).
So either you have to change the CWD before saving the outputs, or use the function Dade mentioned, which accepts a filepath (but you need to know the output type and/or name, I think).

Here's code that's more into the direction of what you want (probably):

Code: Select all

                import os
                from datetime import datetime

                os.chdir(r"D:\my_renders")
                current_dir = os.getcwd()
                print("The files are in", current_dir)

                engine.session.GetFilm().SaveOutputs()
                date_string = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')

                for filename in os.listdir(current_dir):
                    basename, extension = os.path.splitext(filename)
                    if extension.lower() in {"png", "exr"}:
                        os.rename(filename, basename + "_" + date_string + extension)
edit: if you want the imagepipeline outputs to be exr instead of png, you can remove "RGB_IMAGEPIPELINE" and "RGBA_IMAGEPIPELINE" here: https://github.com/LuxCoreRender/BlendL ... ovs.py#L11

CodeHD
Posts: 301
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: BlendLuxCore: Save image while render is paused

Post by CodeHD » Mon Apr 06, 2020 8:46 pm

Here is another updated option, which uses the output directory in the scene tab. Lots of code to choose from now :D
Only problem I observe here is that the filename extension you write overrides the file format setting made below. You might want to get the setting consistent and check if it outputs what you expect. I.e., BYOB was right here:
B.Y.O.B. wrote:
Mon Apr 06, 2020 8:27 pm
... or use the function Dade mentioned, which accepts a filepath (but you need to know the output type and/or name, I think).
howtofname.png

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")

                import os
                from datetime import datetime
                from ..bin import pyluxcore
                import bpy

                dummyfile = bpy.context.scene.render.filepath
                dummyfile = bpy.path.abspath(dummyfile)
                dummyext = dummyfile.split('.')[-1]
                dummyfile = os.path.join(os.path.dirname(dummyfile), '{}'.format(datetime.now().strftime('%Y-%m-%d-%H-%M-%S')) +'.'+dummyext  )
                engine.session.GetFilm().SaveOutput(dummyfile, pyluxcore.FilmOutputType.RGB_IMAGEPIPELINE, pyluxcore.Properties())

        else:
            if engine.session.IsInPause():
                engine.session.Resume()

User avatar
Sharlybg
Donor
Posts: 2009
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: BlendLuxCore: Save image while render is paused

Post by Sharlybg » Mon Apr 06, 2020 9:41 pm

Can you share your python file. I mean the modified ( "" final.py""")
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA

CodeHD
Posts: 301
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: BlendLuxCore: Save image while render is paused

Post by CodeHD » Mon Apr 06, 2020 9:49 pm

Sure
Attachments
final.zip
(3.96 KiB) Downloaded 10 times

User avatar
Sharlybg
Donor
Posts: 2009
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: BlendLuxCore: Save image while render is paused

Post by Sharlybg » Mon Apr 06, 2020 10:16 pm

CodeHD wrote:
Mon Apr 06, 2020 9:49 pm
Sure
Woahou it work :D

just need to reupload the file ""exr"" so i get all the color management stuff applied. It just need now an automatic ""EXR"" reload and save as a specified (jpg/png) extension to be user friendly. Sorry if i'm a bit bothering you. just want to include that in the light group tutorial. It make it so usefull and perfect :mrgreen:

Thanks already for that.
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA

Post Reply