How to snap the right edge of a strip to the playhead instead of the left in video editor

I am making a fade out on a shot. I am using a gamma cross from the shot to a color strip. I have positioned my playhead on the place I want the right edge of the color strip to be, but when I make it snap to the playhead, the left edge of the color strip snaps to it, not the right edge.

I am looking for a way to snap the right edge to the playhead. Maybe an add-on? Or a built-in method?

• If you just want to snap instead of offset, you can select the right head then Shift S; If you want to offset the whole strip, you can press F6 right after Shift S, then substract the strip length from the value by manual typing (length is shown on the N panel). This works for single strip anyway. You do need a small script for multi strips snapping Imho. – Leon Cheung Feb 25 '16 at 1:08
• I am looking to snap the right edge of the strip. I am trying to move the whole strip, but I want the right edge to snap to the playhead, not the left. – Ecko Feb 25 '16 at 1:13

You can do the trick with if len(bpy.context.selected_sequences) > 0: bpy.ops.sequencer.snap(frame = bpy.context.scene.frame_current - bpy.context.selected_sequences[0].frame_final_duration).

Unfortunately you cannot write something specific like an expression into the Frame field fo the RNA SEQUENCER_OT_snap when you use sequencer.snap as the operator identifier for a new key map item in your Input Configuration.

But here's a workaround based on another answer here with the advantage that you can use any scripts saved in text data blocks via a hotkey:

Workaround [use this line of code via a Sequencer Hotkey]

Preparations

1. Save the following Script as a *.py file onto your Computer:

import bpy

bl_info = {
# modified version of zeffiis quick script runner, see https://gist.github.com/zeffii/2b488961226ee1ecefcf
"name": "Sequencer Script Runner",
"author": "Samoth",
"version": (0, 1, 0),
"blender": (2, 7, 6),
"location": "Sequencer, Properties Panel (right)",
"category": "Sequencer"
}

class GlobalScriptRunner(bpy.types.Operator):
bl_idname = "sequencer.script_runner"
bl_label = "Sequencer Script Runner"

def execute(self, context):
# or put own script here...
textblock_name = context.scene.global_script_to_run
textblock = bpy.data.texts.get(textblock_name)
if textblock:
textblock_as_string = textblock.as_string()
exec(textblock_as_string)
return {'FINISHED'}
else:
return {'CANCELLED'}

class ScriptRunnerPanel(bpy.types.Panel):
"""Creates a Panel in the Sequencer Properties Panel"""
bl_label = "Script Runner"
bl_idname = "SCENE_PT_script_runner"
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'

def draw(self, context):
layout = self.layout
layout.label('Script to run from Shortcut')
layout.prop_search(context.scene, "global_script_to_run",  bpy.data, "texts")

def register():
bpy.types.Scene.global_script_to_run = bpy.props.StringProperty()
bpy.utils.register_class(GlobalScriptRunner)
bpy.utils.register_class(ScriptRunnerPanel)

def unregister():
bpy.utils.unregister_class(GlobalScriptRunner)
bpy.utils.unregister_class(ScriptRunnerPanel)
del bpy.types.Scene.global_script_to_run

2. Select it via Install from File... in the Blender User Preferences' (Ctrl Alt U) Add-ons tab and enable it.

3. Save the above Code line that does the trick into a new Text data block in a Text Editor view.

Usage

1. Assign a new Hotkey for the Add-on:
• Select Sequencer and then Sequencer (Global) in the Input tab in Blenders User Preferences.
• Scroll way down and Add New
• Put sequencer.script_runner into the Operator Identifier Field
(You can see that it worked when the Key map events title will change to "Sequencer Script Runner" and the RNA changes to SEQUENCER_OT_script_runner)
• Assign a Hotkey Combination, probably use Keyboard and Shift Alt S
2. Open a Properties Panel in the Video Sequence Editor
3. Select the above created Text data block via its name in the Script Runner panel
4. Just use the newly assigned Hotkey with some selected Strips (I tested it with a Color Strip) and enjoy ;-)

Explanation

You could put your Script lines directly into the Add-ons code into the def execute(self, context): block (where I placed the comment # or put own script here...) and omit the whole Panel creation stuff below. But this will reduce your abilities to this single usage example.

This way with the selectable Text data block you can save multiple ones, name them accordingly and run any selected one of them via the same Hotkey. And this has the huge advantage, that you can do context related stuff in there. You will notice that the above Script line won't work when you simply put it into a Text data block and hit Run Script (which already has a Hotkey assigned). That's due to your cursor not being above the VSE when you hit Run Script and therefore Blenders context is wrong for this to work properly. This isn't the case when you selected a Strip and then call the Script via this Add-on via the newly assigned Hotkey. Then you'd still be hovering over the VSE, so the context for the Script line is fine and it does what you asked for.

• I don't know much about the python workings of Blender, as I'm a bit of a newbie. What does any of this mean? – Ecko Feb 25 '16 at 12:32
• When you post this line of code into a Python Console (You can change any View in Blender into one with the little Icon in the left corner of the Header bar) and hit Enter you'll get the result that you want. And this linked Answer shows you how to use a Hotkey to trigger this line of Python after you pasted it into a new Text Block in a Text Editor View so that you don't have to always press "Run Script". – Samoth Feb 25 '16 at 12:51
• I put the script in the text editor. But I can't figure out what to put in the hotkey setup. text.global_script_runner? I have no idea. – Ecko Feb 25 '16 at 23:04
• @XamuelDvorak I added a detailled explanation. Does this work for you? – Samoth Feb 28 '16 at 21:37
• Yes. But for some reason, it just doesn't work. – Ecko Feb 29 '16 at 1:46

To position the right edge of a strip to the playhead I do the following:

Shift+S to position the left edge then G-25 (assuming 25 is the length of the clip I want to align).

• – Samoth Feb 26 '16 at 14:48