fix render single file

This commit is contained in:
ChristopheSeux
2023-10-09 18:30:06 +02:00
parent f57c4f8133
commit a449f146f1
3 changed files with 20 additions and 5 deletions
+3 -1
View File
@@ -85,6 +85,8 @@ def get_bl_cmd(blender=None, background=False, focus=True, blendfile=None, scrip
def background_render(output=None):
#bpy.context.scene.render.filepath = '{output}'
output = os.path.abspath(bpy.path.abspath(output))
script_code = dedent(f"""
import bpy
bpy.context.scene.render.filepath = '{str(output)}'
@@ -93,7 +95,7 @@ def background_render(output=None):
""")
tmp_blend = Path(bpy.app.tempdir) / Path(bpy.data.filepath).name
bpy.ops.wm.save_as_mainfile(filepath=str(tmp_blend))
bpy.ops.wm.save_as_mainfile(filepath=str(tmp_blend), copy=True)
script_path = Path(bpy.app.tempdir) / 'render_blender_background.py'
script_path.write_text(script_code)