I seem to get two different behaviours from the Blender interface and from external scripts when trying to invoke my addon's operator function object.myaddonoperator()
import bpy
class MyAddonOperator(bpy.types.Operator):
bl_idname = "object.myaddonoperator"
bl_label = "My Addon"
bl_options = {'REGISTER'}
@classmethod
def poll(self, context):
return context.mode == 'OBJECT'
def invoke(self, context, event):
do_stuff()
return {'FINISHED'}
From the console within Blender, calling bpy.ops.object.myaddonoperator('INVOKE_DEFAULT') works just fine, but when using an external script with blender -b -P my_script.py, calling the same results in wm_operator_invoke: invalid operator call 'OBJECT_OT_myaddonoperator'.
What am I doing wrong?