Works with blender 3.2 and above!

Description

This node lets you override the context that a program runs in. The context includes the things you can find in the blend data browser under the context section. It depends on where your mouse currently is. Some operators depend on a specific context.

An example is the close area operator, which you can find in the right-click context menu. This will close whatever area is currently active. To use this operator with Serpens, you probably want to specify which area it should close. This is where you need to override the current context.

Untitled

The Override Context node has two outputs. The With Override output runs first and uses the inputs you add to the node for the current context. In the example, we added an input for the active area and gave it whatever the first area of the type Console is. This way you could close the first 3D view or use a for loop to close all node editors.

(The close area operator from the example can’t be copied directly, you can just copy this line instead: bpy.ops.screen.area_close() )

The Continue output will run after the With Override output and uses the normal context.

You can add overrides by clicking the Add Override button.

Untitled

This will open a popup that shows a message telling you to copy a context. Depending on the type of area, different overrides will exist. The outliner for example has Selected Ids for what collections and objects are selected in that specific outliner, but this option wouldn’t exist in a 3D view.

To copy a context, go to the area you want to get it from, right-click any button or property and click Copy Context.

Untitled

When you do this, the popup will show you what context you copied. Below you will find a list of all the options you can override.

Select the option you are looking for and click the add button. This will add an input to the node with which you can now override that option.

Clicking the add button will print the current value of that option to the console. You can check that message if you are unsure what value the newly created input expects.

Finally, the blend data browser can be useful for exploring the different options in your context. In addition to the names in this list, you can also see the data type and its options.

Outputs

With Override: The program nodes connected to this output will use the overrides you provide as inputs

Continue: The program nodes connected to this output will run after the With Override input and use the previous context