It is possible to run the original operator in an override by temporarily unregistering the overriding class during invoke() and execute() and that way avoiding infinite recursion (at least in Blender 2.93). Combining that with a technique for forwarding properties from this forum post https://blenderartists.org/t/extending-built-in-operator/1257955/4 allows you to write a forwarding operator.
def keywords_from_prop(p_rna):
kw = {}
for kwname in ("name", "description", "default", "min", "size"
"max", "soft_min", "soft_max", "precision"):
value = getattr(p_rna, kwname, None)
if value is not None:
kw[kwname] = value
if p_rna.type == 'ENUM':
kw["items"] = tuple((i.identifier, i.name, i.description)
for i in p_rna.enum_items)
return kw
def props_from_op(idname):
import _bpy
props_dict = {}
op_rna = _bpy.ops.get_rna_type(idname)
for p in op_rna.properties:
if p.identifier == "rna_type":
continue
prop = getattr(bpy.props, p.rna_type.identifier)
kwargs = keywords_from_prop(p)
props_dict[p.identifier] = prop(**kwargs)
return props_dict
class NewOperator(bpy.types.Operator):
bl_idname = "object.delete" # override delete operator and copy all its attributes
bl_label = bpy.ops.object.delete.get_rna_type().description
# if we have our own undo steps, the REDO panel isn't usable
#bl_options = {'UNDO','REGISTER'}
__annotations__ = props_from_op("object.delete")
@classmethod
def poll(cls, context):
return True # you will have to write your own poll method
def execute(self, context):
# unregister self before calling original operator to avoid infinite recursion
bpy.utils.unregister_class(NewOperator)
# execute operator: use True as 3rd parametre to register undo step
ret = bpy.ops.sequencer.split({}, 'INVOKE_DEFAULT', True, **self.as_keywords())
bpy.utils.register_class(NewOperator)
return ret
Note that it could be hard to get the redo panel to work with this technique. In this example I am registering the undo step with the original operator. This way the redo panel keeps working but redoing will NOT trigger your operator again, only the original one. Operators with a modal phase or ones that adjust properties in the invoke phase are also harder to use in this way.
execute
orinvoke
if you "want to replace (override) the original one"? $\endgroup$