13
$\begingroup$

The documentation says that I can invoke an operator with a different execution context, either invoking or executing it. What I know is that invoke will most often set the parameters from the context and execute will execute the operator with already set parameter - most of the time.

Yet, there are many more execution contexts I can pass, namely ‘INVOKE_DEFAULT’, ‘INVOKE_REGION_WIN’, ‘INVOKE_REGION_CHANNELS’, ‘INVOKE_REGION_PREVIEW’, ‘INVOKE_AREA’, ‘INVOKE_SCREEN’, ‘EXEC_DEFAULT’, ‘EXEC_REGION_WIN’, ‘EXEC_REGION_CHANNELS’, ‘EXEC_REGION_PREVIEW’, ‘EXEC_AREA’, ‘EXEC_SCREEN’.

I think that the prefix INVOKE/EXEC decides if the the operator will be invoked or executed respectively. But what is the meaning of the second part of the execution context?

I always use DEFAULT in my scripts, but I wondered, what the effect of using the others were?

$\endgroup$
1
  • 1
    $\begingroup$ This long dead question is the first result I get on google when I search for the names of the execution contexts and blender, so I'll add some breadcrumbs. Javier's answer is right about region/area/screens, but I'm unclear on the differences between the various region contexts (Preview probably refers to the compositor preview and channels might refer to the channel region of the graph editor, but why they're this specific, don't know). This isn't even documented in the Blender source code, so I'll have to read the code to figure it out. If I do that I'll write an answer. $\endgroup$
    – jwrush
    Jul 2 '21 at 20:01
2
$\begingroup$

The operators are object oriented, meaning which contexts are valid for an operator and what they ultimately do is left up to each specific operator. In practice it seems like they have the same effect as passing a context object, or setting the operator_context value -- to change where in the UI the operator is effected.

The context values can be understood to mean the following, based upon what they're named:

  1. Each of the context names starts with INVOKE_ and EXEC_, which indicates if the operator will be invoked or executed. (When executed, an operator's execute() method is called and when invoked both execute() and invoke() are called.)

  2. The second part of the name indicates what the scope of the operator is for this invocation or execution.

    1. DEFAULT indicates that the operator's default context is used.
    2. SCREEN and AREA refer to levels of the Blender UI, as Javier pointed out. Areas are the rectangles of the window that you can resize and change between 3D Viewport, Image Editor, Node Editor, etc. Screen is the old name for what we now call Workspaces, the top-level tabs that are built out of areas, so like Layout, Modeling, Shading, etc, in the default start-up file.
    3. Regions are the level of widgets one level smaller than areas. They are seldom used as valid contexts for operators, which is why which ones exist are so shattershot. PREVIEW refers to the preview in the Compositor. CHANNELS refers to the channel region of the render preview. As for WIN, it seems to indicate the active region of the active window, which in practice seems to be the same as DEFAULT.
$\endgroup$
0
$\begingroup$

Probably you know more than me, but i think it is related to the words itself or the concepts behind it. Area, Screen and Region are pointing to where the oops are meant to be executed/invoked i think. "But dont know whats the diference between exec and invoke." now i do. thanks, (i dont use many scripted oops) You know, Area, Screen and Region are the names blender gives internally to the the user interface diferent componets. see: https://docs.blender.org/manual/en/dev/interface/window_system/screens.html

https://docs.blender.org/manual/en/dev/interface/window_system/areas.html

https://docs.blender.org/manual/en/dev/interface/window_system/regions.html

hope useful.

$\endgroup$

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.