OK, I was trying to see if I could get one of my addons to work in 2.8. I need to create a new scene, new collection, and then add some objects to the new collection. I need to switch my scenes before I add my collection and my objects. Right now, my objects are added to the current scene I am on, unless I switch it. Is it possible to switch scenes anymore in 2.8 with python? In 2.79 you could do something like this ,but it no longer works.
#Get current scene
my_current_scene = bpy.context.screen.scene
#Switch to my new scene
bpy.context.screen.scene = bpy.data.scenes['switch to different scene']
#.......add my stuff to my new scene here......
#Now switch back to the previous scene
bpy.context.screen.scene = my_current_scene
@brecht Yeah, that did the trick. I ran into a issue I never had before and not sure if you would know what’s going on. If I run this code from the text editor it works like I want it to ,but if I try it as a operator it doesn’t work the same. As a operator it adds the new scene, switches to the scene, but it adds the sphere to the previous scene and errors out at renaming the sphere. Any ideas why that’s happening?
#Add new scene
new_scene = bpy.data.scenes.new(name='My New Scene')
#Make "My New Scene" the active one
bpy.context.window.scene = new_scene
bpy.ops.mesh.primitive_uv_sphere_add(segments=64, ring_count=32, location=(0.0, 0.0, 0.0))
#Add smooth shading
act_obj = bpy.context.active_object
act_obj.name = 'My Sphere'