Skip to content

Instantly share code, notes, and snippets.

@the-simian
Created July 16, 2018 14:57
Show Gist options
  • Save the-simian/4c5ec43bf071b812d71d8846ce8e8b06 to your computer and use it in GitHub Desktop.
Save the-simian/4c5ec43bf071b812d71d8846ce8e8b06 to your computer and use it in GitHub Desktop.
Blender Script to Name each animation Frame after the marker and number the frames per animation, rather than per sequence
import bpy
import os
import time
# get the scene
scn = bpy.context.scene
# get the output path
output_path = scn.render.filepath
starting_filepath = output_path
all_unsorted_markers = scn.timeline_markers.values()
all_markers = sorted(all_unsorted_markers, key=lambda x: x.frame)
current_marker_index = 0
current_marker = all_markers[current_marker_index]
for frame in range(scn.frame_start, scn.frame_end):
next_marker_index = current_marker_index+1
if len(all_markers) > next_marker_index :
if all_markers[next_marker_index].frame == frame :
current_marker_index += 1
current_marker = all_markers[current_marker_index]
marker_name = current_marker.name
animation_frame_number = str(frame - current_marker.frame)
scn.frame_set(frame)
print("Progress :")
print(str(current_marker_index) + " | " + str(len(all_markers)))
print("Marker / Frame :")
print(marker_name + " | " + animation_frame_number)
scn.render.filepath = os.path.join(output_path,marker_name + "-" + animation_frame_number + ".png")
bpy.ops.render.render( write_still=True )
bpy.context.scene.render.filepath = starting_filepath
print("DONE")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment