How to create new "Layout" workspace?

I am trying this command to create a new ‘Layout’ workspace but it does not work. Probably it has to do something with context.

import bpy
ok = bpy.ops.workspace.append_activate(idname='Layout')
print(ok)
# returns {'CANCELLED'}

What error are you getting, or what output is in the console?

Hi, I just found that the filepath parameter is needed as well.

In this file: blender\3.1\scripts\addons\render_povray\base_ui.py

import bpy
bpy.ops.workspace.append_activate(
    idname='Layout',
    filepath= bpy.utils.user_resource('CONFIG', path='startup.blend')
)

In the Blender API it said that the filepath was optional, but anyway…

2 Likes