import bpy class GPEXP_OT_render_scene_switch(bpy.types.Operator): bl_idname = "gp.render_scene_switch" bl_label = "Render Scene Switch" bl_description = "Switch between render" bl_options = {"REGISTER"} @classmethod def poll(cls, context): return True # mode : bpy.props.StringProperty(default='NORMAL', options={'SKIP_SAVE'}) def execute(self, context): scenes = bpy.data.scenes if len(scenes) < 2: self.report({'ERROR'},'No other scene to go to') return {"CANCELLED"} if context.scene.name == 'Render': scn = scenes.get('Scene') if not scn: # get the next available scene self.report({'WARNING'},'No scene named "Scene"') slist = [s.name for s in scenes] scn = scenes[(slist.index(bpy.context.scene.name) + 1) % len(scenes)] else: scn = scenes.get('Render') if not scn: self.report({'ERROR'},'No "Render" scene yet') return {"CANCELLED"} self.report({'INFO'},f'Switched to scene "{scn.name}"') bpy.context.window.scene = scn return {"FINISHED"} classes=( GPEXP_OT_render_scene_switch, ) def register(): for cls in classes: bpy.utils.register_class(cls) def unregister(): for cls in reversed(classes): bpy.utils.unregister_class(cls)