I want to code a python script to display a render preview of a scene (using Cycles) directly without clicking the “Rendered” item in space view button.
I have checked the python command of “Rendered” is:
bpy.data.screens[“Default”].(null) = ‘RENDERED’
So I type the following codes in the “Text Editor”
python code:
" import bpy
bpy.context.scene.render.engine = ‘CYCLES’
bpy.data.screens[“Default”].(null) = ‘RENDERED’
"
and click “Run Script” button.
However, an info [Editor Type] displays :
"bpy.data.screens[“Default”].(null) = ‘RENDERED’
^
SyntaxError: invalid syntax location:<unkonwn location>: -1 Error: Python script fail, look in the console for now…."
The scene is not changed, and the screen lay-out is “Default” .
I tested the script in both 2.67a and 2.65 in two different desktops. The problem is the same.
Could anyone give me some ideas to fix this problem?
screens = UI layouts, there is only one active layout.
areas = the editor rectangles in a screen, area.type defines the editor type (e.g. OUTLINER, VIEW_3D etc.)
regions = “sub-editor rectangles”, better known as sidebars. Note that an area’s header is also a region.
spaces = data stored along with an area (like viewport_shade). Not sure why / when there can be multiple spaces. Note that VIEW_3D doesn’t store most data in spaces[0]., but in spaces[0].region_3d. (or region_quadview.* respectively)