Impossible to call an operator from the VSE

Hi all,

I’m working on a pie menu to speed up my workflow with VSE and I struggle with several issues as it is my first pie menu.

I’ve followed Sebastian Koening tutorial to create the my own pie and decided to create my own operators to allow more customization in the future. (For now, I only try to get basic operation in the pie.)

Here is my code :


import bpy
from bpy.types import Menu

# spawn a selection of tools for speeding up VSE workflow


#Select all strips to the left
class SelectAllToTheLeft(bpy.types.Operator):
    bl_idname = "sequencer.allleft"
    bl_label = "All strips to the left"
    
    def execute(self, context) : 
        bpy.ops.sequencer.select(left_right='LEFT', linked_time=True)
        return {'FINISHED'}
    

    
#Select all strips to the right
class SelectAllToTheRight(bpy.types.Operator):
    bl_idname = "sequencer.allright"
    bl_label = "All strips to the right"
    
    def execute(self, context) : 
        bpy.ops.sequencer.select(left_right='RIGHT', linked_time=True)
        return {'FINISHED'}

#Set current override camera as active camera in the viewport
class OverrideToActiveCamera(bpy.types.Operator):
    bl_idname = "sequencer.overrideactivecamera"
    bl_label = "Overide Camera to active"
    
    def execute(self, context) :
        print("coucou")
        return {"FINISHED"}


class VSE_PIE_riton(Menu):
    bl_idname = "pie.vsetools"
    bl_label = "VSE Tool"

    def draw(self, context):
        layout = self.layout

        pie = layout.menu_pie()

        pie.operator("sequencer.allleft", text = "All strips to the left", icon="BACK")
        pie.operator("sequencer.allright", text = "All strips to the right", icon="FORWARD")
        pie.operator("sequencer.reload", text = "Reload strips",icon="FILE_REFRESH")
        pie.operator("sequencer.overrideactivecamera", text = "Override to Active Camera", icon = "SCENE")


def register():
    #tools
    bpy.utils.register_class(SelectAllToTheLeft)
    bpy.utils.register_class(SelectAllToTheRight)
    bpy.utils.register_class(OverrideToActiveCamera)
    
    #pie
    bpy.utils.register_class(VSE_PIE_riton)
    
    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name="Sequencer")
    kmi = km.keymap_items.new("wm.call_menu_pie","S", "PRESS").properties.name="pie.vsetools"


def unregister():
    #tools
    bpy.utils.unregister_class(SelectAllToTheLeft)
    bpy.utils.unregister_class(SelectAllToTheRight)
    bpy.utils.unregister_class(OverrideToActiveCamera)
    
    #pie
    bpy.utils.unregister_class(VSE_PIE_riton)


if __name__ == "__main__":
    register()


So, as you can see, it is really simple and for now, nothing is really happening and I have only a simple operation in each of my custom operator (I’ll add several operation for each operator later on)

The thing is my operator are called from the pie menu, operators bpy.ops.sequencer.select(left_right=‘LEFT’, linked_time=True) and bpy.ops.sequencer.select(left_right=‘RIGHT’, linked_time=True) won’t work.

In the console, I have :

wm_operator_invoke: invalid operator call 'SEQUENCER_OT_select'

I’ve done some research with on google and this topic comes first but it doesn’t answer my problem. I’m a python newbie so I may do something terribly wrong here but I don’t know why.

If you know where I’m wrong, could you please help me ?

Thanks a lot :slight_smile:

This is more than a month old with no replies, so in case it helps others… I’ve encountered exactly the same issue. I only need the strip to the left of the cursor selected, so my workaround is (the cursor is known to be on a cut between two strips):


for strip in context.selected_sequences:
	if strip.frame_final_end == context.scene.frame_current:
		bpy.ops.sequencer.select_all(action='DESELECT')
		strip.select=True
		break

I haven’t tested whether this is too slow when there are hundreds of strips in the sequencer. Because in my case I already have strips to the right of the cursor selected, I could have optimised the above code simply by enlarging the selection to include the strip on the left and then iterating through. This would be faster as there tend to be fewer strips to the right when editing, at least initially. However, I found that “bpy.ops.sequencer.select_less()” and “.select_more()” do the opposite of what’s expected. If that’s a bug, a fix at some point in the future would break the script.

This question is more than a month old with no replies, but if it helps others… I’ve encountered the same issue and solved it with a workaround. In my case I want to select all strips to the left of the cursor:


bpy.ops.sequencer.select_all(action='DESELECT')
for strip in bpy.context.sequences:
	if strip.frame_final_end <= bpy.context.scene.frame_current:
		strip.select=True

I haven’t tested this for speed on a file with hundreds of strips, I hope it doesn’t slow down much. The code could be optimised by selecting to the right instead, then inverting the selection. This should be faster as there are usually fewer strips to the right, at least initially.

In the course of this work, I also discovered that “bpy.ops.sequencer.select_less()” selects more and “.select_more()” selects less. That just makes me love Blender more! :wink: