Switching workspaces in Blender using Python API

Workspaces in Blender are saved sets of work areas (windows of the desired type). Typically, switching between them is done by clicking on the tab with the name of the workspace at the top of the Blender UI. We can also switch between workspaces using the Blender Python API.

We can get a list of all available workspaces using the following command:

The currently active workspace is stored in the “context.window.workspace” parameter:

To switch to the desired workspace, we need to assign this parameter the value of the required workspace:

Workspaces can be imported from external Blender files using the “bpy.ops.workspace.append_activate” operator.

For example, to import the “Shading” workspace from the startup file, we need to execute this operator as follows:

The specified workspace will be imported into the current session and Blender will switch to it.

5 1 vote
Article Rating
Subscribe
Notify of
guest

1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
cscholl
cscholl
5 months ago

didn’t know you can import workspaces, it gives me ideas, thanks !