I`m try to set active scene thru python code that runs from cmd. bpy.context.window is always None in this case.
Can someone please explain why and if there is other ways to set active scene ?
The way to set the active scene is
bpy.context.window.scene = bpy.data.scenes['Scene']
replacing the right hand side of the assignment with whatever scene you want to use for the new context. See the Window page for details on the window type.
In case someone gets None when using bpy.context.window consider use this solution:
def get_context_window():
for window in bpy.context.window_manager.windows:
if window:
return window
return None
import bpy
window = get_context_window()
scene = bpy.data.scenes.get('some_scene')
window.scene = bpy.data.scenes.get(scene)