Select Scene from Python

Hi there,

I’m using Blender 2.55 on Windows 7.

I try to select a scene from Python, make it the active scene.
Access any scene from python is really no problem, but there seems no way to make a scene the current scene ([“SomeScene”] -> bpy.context.scene).
I have to select it manually from the UI.
Any suggestions?

Some times I have to try and try and search for hours over hours, just to post a question and find the answer on myself a few minutes later…

scn =‘FULL_COPY’)

though it sets the newly created scene as the active scene only.
But how can I set an already created scene as the active one?

Changing the scene can’t be done directly via the context (e.g. context.scene = my_scene). This is because it’s a read-only property. The location to change it is at the screen level. An example:

import bpy

# retrieve all scenes
list_of_all_scenes =

# currently active scene
current_scene = bpy.context.scene

# change the scene
bpy.context.screen.scene = list_of_all_scenes[2]

This changes the scene of the currently active screen (as a normal user I’d describe a screen as a program window, but Blender uses the word window for something else). If you’ve got several screens you have to change the scene of each one of them.

It’s hard to find this kind of information, but your best bet is probably the API reference. If you go to the Types module and then scroll down you’ll find the Scene type. At the bottom of that page there is a list of references which is really helpful (in this case that’s also where Screen.scene is mentioned).

Many thanks!
It’s really hard to find but this way I learned a lot about almost everything else while studying the API…
Thanks for the hint to list of references! That will do in the future!


I’ve posted this request to a couple of other threads, but I haven’t gotten a response - help, please? and THANKS…

I’m looking to render multiple scenes in a .blend file via python. So I need to change the scene, and then call bpy.ops.render.render(), but the render call doesn’t work on the new (second) scene - it just renders the first scene again and again.

I found a strange behavior that may be related to this problem: When I change scenes from “Scene1” to “Scene2” by calling

bpy.context.screen.scene =[‘Scene2’]

… and then check on the other screens’ scenes via

for scr in

… the other screens (for example, the modeling screen, or the compositing screen) have not changed over to the new scene. The same thing happens if I switch screens via the GUI - for example, if I change from “Scene1” to “Scene2” while in the modeling screen, and then I switch to the compositing screen, Blender will switch back to “Scene1” on me along with the switch back to the modeling screen…

I tried to set all the screens to the same scene using a for loop:

for scr in
scr.scene =[‘Scene2’]

… but it did not work. When I checked the screens later with:

for scr in

… only the active screen had changed to the new scene. It seems to me that ALL the screens should always be associated with the same (active) scene - is this a bug in the API? Any chance of a fix? Or is there anything else I can do?

THANKS for your help…