I find myself often using the scroll wheel to zoom really close, then out far again in the sequence editor. It would be nice if I could link a shortcut to a function that changes the zoom level. Unfortunately I can only find the commands bpy.ops.sequencer.view_selected() and bpy.ops.sequencer.view_all() in the api, but neither are quite what I’m looking for.
I thought maybe I could have the script make a temporary text strip 5 frames long at the location of the CTI, then call view_selected(), but it doesn’t work. The text strip gets added, and the view_all() command is called without error, but the sequencer does not zoom in.
Does anyone have a better idea for how to zoom in on the current time indicator using python?
Well actually I spoke too soon. The method I explained above works fine as long as you do it as a keyboard shortcut (instead of running it from the text editor.) I’ll be putting my full addon up on github later, but for anyone curious to see the operator I wrote for doing this, here it is:
import bpy
class ZoomCTI(bpy.types.Operator):
bl_label = 'Zoom to CTI'
bl_description = 'Zoom in on the current time indicator'
bl_idname = 'sequencerextra.zoom_cti'
def execute(self, context):
scene = context.scene
start = scene.frame_current
active_strip = scene.sequence_editor.active_strip
selection = context.selected_editable_sequences
zoom_level = 10
bpy.ops.sequencer.select_all(action='DESELECT')
bpy.ops.sequencer.effect_strip_add(
frame_start=start, frame_end=start+zoom_level,
channel=1, type='TEXT')
bpy.ops.sequencer.view_selected()
bpy.ops.sequencer.delete()
for strip in selection:
strip.select = True
scene.sequence_editor.active_strip = active_strip
return {'FINISHED'}