How do I override an operator that was written in C?

I’m looking for a way to override the operator bpy.types.OBJECT_OT_shape_key_move as well as a few others. I’ve basically finished writing labels into shape keys, but I need other scripts/users to call my functions instead of the originals, so the state of my labels don’t become invalid. I still need to be able to call the original function bpy.ops.object.shape_key_move in the operator I replace it with, but other scripts in blender should only see mine. Basically something like this, but with an operator that was originally written in C. At least, I think these were written in C.

sorry for bumping, but in case anyone finds this thread, here’s an easy solution:

wrap the “original” operator inside a custom python operator, e.g.:

import bpy

class SimpleOperator(bpy.types.Operator):
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"

    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        # Call any operator (C/python) here...
        return {'FINISHED'}

def register():

def unregister():

if __name__ == "__main__":

    # test call

The example you’ve given is indeed the standard method of creating an operator. I certainly hope it’s useful to anyone who finds this thread. However, the original question was asking how to override/monkey patch a C operator, in order to extend the original functionality. The essential idea was that ALL parts of blender, including scripts written by other authors would continue to call the original operator (bpy.ops.object.shape_key_move in my example) but that operator would be extended to support further functionality (labels in my example).

i admit it’s the most simple “wrapping” of a c-operator. However, it shows what is possible: you can perform tasks before, then call c-op (may pass parameters), perform tasks afterwards. There is nothing more you can do, and probably won’t be able in future as well. How could python hook up to the middle of the compiled c-code? Unless you inject into the exe, i don’t see a way here.

This is the most i could money-hijack (?) the border select for my task:

import bpy, bmesh

bl_info = {
    "name": "Border Select Intersection",
    "author": "CoDEmanX",
    "version": (1, 1),
    "blender": (2, 66, 0),
    "location": "View3D > Spacebar > Border Select Intersect",
    "description": "Make a selection, then run this operator to border select the desired selection intersection",
    "warning": "",
    "wiki_url": "",
    "tracker_url": "",
    "category": "3D View"}

def store_sel():
    bm =
    if 'select_old' in
        sel =['select_old']
        sel ="select_old")
    for v in bm.verts:
        if not v.link_loops: # IndexError?!
        v.link_loops[0][sel] =
def restore_sel(me):
    bm =
    sel =['select_old']
    for v in bm.verts:
        if not v.link_loops:
        if not ( and v.link_loops[0][sel]):

    #bm.select_mode = {'VERT'}

def changed_sel():
    bm =
    sel =['select_old']
    for v in bm.verts:
        if not v.link_loops:
        if != v.link_loops[0][sel]:
            return True
    return False

class MESH_OT_select_border_intersect(bpy.types.Operator):
    """Border select an existing selection and make only the intersection selected"""
    bl_idname = "mesh.select_border_intersect"
    bl_label = "Border Select Intersect"
    bl_options = {'REGISTER'}
    init = True
    bm = None

    def modal(self, context, event):
        if changed_sel():
            return {'FINISHED'}

        elif event.type in {'RIGHTMOUSE', 'ESC'}:
            return {'CANCELLED'}

        if self.init:        
            bpy.ops.view3d.select_border('INVOKE_DEFAULT', extend=False)
            self.init = False

        return {'RUNNING_MODAL'}
        #return {'PASS_THROUGH'} # Makes no difference

    def invoke(self, context, event):
        if (context.object and 
            context.object.type == 'MESH' and
            context.object.mode == 'EDIT'):
   = bmesh.from_edit_mesh(
            return {'RUNNING_MODAL'}
  {'WARNING'}, "No active editmesh, could not finish")
            return {'CANCELLED'}

def register():

def unregister():

if __name__ == "__main__":