Skip to content

Instantly share code, notes, and snippets.

@sirkkalap
Created November 30, 2020 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirkkalap/1999c994d26e7be877708f9b72a23810 to your computer and use it in GitHub Desktop.
Save sirkkalap/1999c994d26e7be877708f9b72a23810 to your computer and use it in GitHub Desktop.
Write Blender sequencer markers to a CSV file
# From: https://www.quollism.com/b/archives/113
#
# "You can copypaste this script straight into Blender’s text editor and hit
# “Run Script” to output filename_frames.csv in the directory right next to
# your currently open file. Yay!"
#
import bpy
import csv
import os
C = bpy.context
markers = {}
for m in C.scene.timeline_markers:
markers[m.frame] = m.name
k = list(markers.keys())
k.sort()
frameinfo = []
for frame in k:
frameinfo.append( [markers[frame], frame] )
with open(os.path.splitext(bpy.data.filepath)[0]+'_frames.csv', 'w', newline='') as f:
writer = csv.writer(f)
writer.writerow( [ "Marker", "Frame" ] )
for row in frameinfo:
writer.writerow(row)
print("All done!")
@Hottabraver
Copy link

Hottabraver commented Dec 9, 2023

Really Works.
Only for timeline.
I go to search solution for reading this files.
Thanks !

@sirkkalap
Copy link
Author

Please thank the original author at From: https://www.quollism.com/b/archives/113 . This is just a fork. :)

@sirkkalap
Copy link
Author

sirkkalap commented Dec 9, 2023

If you are looking for a solution to read the markers back in, here is a ChatGPT generated reverse script (untested) to do that:

import bpy
import csv
import os

def import_markers_from_csv(csv_file):
    with open(csv_file, 'r') as f:
        reader = csv.DictReader(f)
        markers_data = list(reader)

    for data in markers_data:
        frame = int(data['Frame'])
        name = data['Marker']
        bpy.context.scene.timeline_markers.new(name=name, frame=frame)

csv_file_path = "path/to/your/filename_frames.csv"
import_markers_from_csv(csv_file_path)
print("Markers imported from CSV file.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment