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 script­ing.

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 after­wards.

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 com­ma.

Here’s the script we would run in the source blend­file.

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 blend­files!

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 inter­face.


Try out Render+ today!

Blender(Blender, Python)Last updated 21.08.2020
All the posts you can read

No comments yet

Leave a Reply

Your email address will not be published.