Hi, I put below code in scripts\startup\bl_ui\space_topbar.py ,when in single windows, I get the result what I want.
But when I open some new main windows from this opened Blender ,the behavior of the script is not normal as single windows one . no matter how I change the bpy.context.window.scene to bpy.data.window_managers[-1].windows[-1].scene the workspace can’t set to right scene. Am I missing any context in the multi-mian window?
def workspace_scene_link_keeper():
if (bpy.context.workspace.name == '2D DRAW'):
if(bpy.context.scene.name != 'first_floor'):
if('first_floor' in bpy.data.scenes):
bpy.context.window.scene = bpy.data.scenes['first_floor']
else:
bpy.data.scenes.new('first_floor')
bpy.context.window.scene = bpy.data.scenes['first_floor']
elif(bpy.context.workspace.name == '3D DRAW'):
if(bpy.context.scene.name != 'Scene' ):
bpy.context.window.scene = bpy.data.scenes['Scene']
return 0
bpy.app.timers.register(workspace_scene_link_keeper)