Can I somehow make the poll method of my operator sensitive to whether the operator is being invoked or executed?
Take for example:
from bpy.types import Operator
class TestOp(Operator):
bl_idname = "test.test"
bl_label = "Test operator"
@classmethod
def poll(self, context):
return False
def execute(self, c):
print("Executed, just executing")
def invoke(self, c, e):
print("Invoked, taking user input")
I want to rework the poll method so that, when the operator is executed, it always returns True (run from scripts, etc.., assume parameters are set).
When invoked, the context has to fit in a way that the user is able to input the needed parameters. For the sake of the example, let's say we need an object with context.object.type == 'MESH'
in context.mode == 'EDIT_MESH'
.
Is there a way to determine the way the operator will be invoked inside its poll
method?
invoke()
orexecute()
return {'CANCELLED'}
to abort.poll()
is supposed to determine whether an operator is able to run at all, and shouldn't check for something that isn't decided yet (modal user input in invoke). $\endgroup$