System Information
Operating system: Windows 10
Graphics card: <irrelevant>
Blender Version
Broken: 2.82.7 (also broken in 2.79)
Worked: Never
Short description of error
When the active scene is changed by a script from the 'Properties' panel context, the bpy.context.scene property is not updated correctly. It seems to work fine from other contexts (e.g. the 'Text Editor' context, the '3D View' context, etc.)
Exact steps for others to reproduce the error
- Open the default startup file
- Run the following script:
import bpy
class TEST_OT_make_scene(bpy.types.Operator):
bl_idname = "test.make_scene"
bl_label = "Make Scene"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
scn = bpy.data.scenes.new("My Scene")
scn.world = bpy.data.worlds.new("My World")
bpy.context.window.scene = scn
print(bpy.context.window.scene.name, bpy.context.scene.name)
self.report({"INFO"}, bpy.context.window.scene.name + " == " + bpy.context.scene.name)
return {"FINISHED"}
class RENDER_PT_test_case(bpy.types.Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_label = "TEST CASE"
bl_idname = "RENDER_PT_test_case"
bl_context = "render"
@classmethod
def poll(self, context):
return True
def draw(self, context):
self.layout.operator("test.make_scene")
bpy.utils.register_class(TEST_OT_make_scene)
bpy.utils.register_class(RENDER_PT_test_case)- Navigate to the 'Render' properties panel, and scroll down to the new tab titled "TEST CASE". Click on the operator. If it worked correctly, the names reported to the Blender UI should match.