Skip to content

Commit

Permalink
Merge pull request #47 from p2or/skip-existing-frames, closes #45
Browse files Browse the repository at this point in the history
placeholders
  • Loading branch information
p2or authored Jun 10, 2023
2 parents b9af15a + c6ceddc commit 5c19923
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions loom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3798,15 +3798,22 @@ def frame_repath(self, scene, frame_number):
k.base_path = os.path.join(replace_globals(v["Folder"]), of)

def start_render(self, scene, frame, silent=False):
rndr = scene.render # Skip frame, if rendered already
rndr = scene.render
if not rndr.use_overwrite and os.path.isfile(rndr.filepath):
self._skipped_frames.append(frame)
self.post_render(scene, None)
if not silent:
self.post_render(scene, None)
else:
print("Skipped frame: {} (already exists)".format(frame))
else:
if rndr.use_placeholder and not os.path.isfile(rndr.filepath):
open(rndr.filepath, 'a').close()

if silent:
bpy.ops.render.render(write_still=True)
else:
bpy.ops.render.render("INVOKE_DEFAULT", write_still=True)

if frame not in self._rendered_frames:
self._rendered_frames.append(frame)

Expand Down Expand Up @@ -3844,7 +3851,7 @@ def final_report(self):
mf=i[0], sf=str(i[1]).split(".")[1]) for i in self._skipped_frames)
else:
skipped = ','.join(map(str, self._skipped_frames))
self.report({'WARNING'}, "{} skipped (would overwrite existing file(s))".format(skipped))
self.report({'WARNING'}, "Frame(s): {} skipped (would overwrite existing file(s))".format(skipped))

def execute(self, context):
scn = context.scene
Expand Down Expand Up @@ -3906,7 +3913,6 @@ def execute(self, context):

""" Render silent """
if self.render_silent:

""" Apply custom Render Preset """
if self.render_preset and self.render_preset != "EMPTY":
bpy.ops.script.execute_preset(
Expand All @@ -3918,6 +3924,7 @@ def execute(self, context):
self.start_render(scn, frame_number, silent=True)

""" Reset output path & display results """
self.final_report()
self.reset_output_paths(scn)
return {"FINISHED"}

Expand Down

0 comments on commit 5c19923

Please sign in to comment.