Copying markers in Blender is easy

Ever want­ed to copy mark­ers from one scene to anoth­er? Blender does­n’t have a built-in method to do this but we can do it with some Python.

Markers are stored as scene prop­er­ties, much like Render set­tings or units, that’s why we can’t copy them indi­vid­u­al­ly. The alter­na­tive is to append/duplicate the entire scene and then remove what we don’t want. But man that’s a waste of time. We can get this done much faster with the ancient arts of Python scripting.

If you have a cam­era bound to the mark­ers, and the cam­era is also avail­able in the tar­get scene, you can set it afterwards.

import bpy

source_scene = bpy.data.scenes['Scene']
target_scene = bpy.data.scenes['Other Scene']


for marker in source_scene.timeline_markers:
    new_marker = target_scene.timeline_markers.new(name=marker.name, frame=marker.frame)

    # Camera (if it's available in the other scene)
    new_marker.camera = marker.camera

Sharing markers between blendfiles

Copying mark­ers between blend­files is a lit­tle more involved but not hard. We need a file to write the mark­ers and then read them from it. You can use any for­mat you want to do this, I’m going to use a sim­ple one:

  • One Marker per line
  • First the frame num­ber, then the mark­er’s name. Separated by a comma.

Here’s the script we would run in the source blendfile.

import bpy

source_scene = bpy.data.scenes['Scene']

# Don't forget to change this!
filename = '/path/to/file/markers.txt'

with open(filename, 'w') as stream:
    for marker in source_scene.timeline_markers:        
        stream.write(f'{marker.frame},{marker.name}\n')

Once we have writ­ten the file, we can read from it and cre­ate the mark­ers in the tar­get blend­file. We use the strip() func­tion to remove the new­lines (\n) from the name.

import bpy

target_scene = bpy.data.scenes['Other Scene']

# Don't forget to change this!
filename = '/path/to/file/markers.txt'

with open(filename, 'r') as stream:
    for line in stream.readlines():
        frame, name  = line.strip().split(',')
        target_scene.timeline_markers.new(name=name, frame=int(frame))

That’s all there is to it. Don’t for­get you can also keep the mark­ers file around and import it into mul­ti­ple blendfiles! 

Batch rendering is complicated

But it does­n’t have to be! Render+ lets you set­up, run batch­es and a whole lot more from the com­fort of Blender’s interface. 


Try out Render+ today!

All the posts you can read
BlenderBlender, Python21.08.2020