I've seen the functions called poll and invoke used in scripts. I'm curious what these are for and when they are called.


For a comprehensive description of operators and their use see: https://docs.blender.org/api/current/bpy.types.Operator.html

For a quick run-down

  • poll, checked before running the operator, which will never run when poll fails, used to check if an operator can run, menu items will be greyed out and if key bindings should be ignored.
  • invoke, Think of this as "run by a person". Called by default when accessed from a key binding and menu, this takes the current context - mouse location, used for interactive operations such as dragging & drawing. *
  • execute This runs the operator, assuming values are set by the caller (else use defaults), this is used for undo/redo, and executing operators from Python.
  • draw called to draw options, typically in the tool-bar. Without this, options will draw in the order they are defined. This gives you control over the layout.
  • modal this is used for operators which continuously run, eg: fly mode, knife tool, circle select are all examples of modal operators. Modal operators can handle events which would normally access other operators, they keep running until they return FINISHED.
  • cancel - called when Blender cancels a modal operator, not used often. Internal cleanup can be done here if needed.

* - note, button layouts may set the context of operators to invoke or execute. See: https://docs.blender.org/api/current/bpy.types.UILayout.html#bpy.types.UILayout.operator_context

  • $\begingroup$ I've never been quite sure of this, is invoke called after you make changes in the redo panel? It seems from the description like it shouldn't be, but I can't find anything for certain. $\endgroup$
    – Tim M.
    Dec 13 '18 at 18:39
  • $\begingroup$ how do you ignore the poll function when calling the operator from a handler in python? I always get nonetype object has no attirbute type (because that's what my poll is asking for). I can check if it's non, but I just wondered if there's a way to bypass it completely? EXEC_DEFAULT doesn't work. $\endgroup$ May 25 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.