I can change the window type to "node editor" with
bpy.context.window_manager.windows.screen.areas.type = 'NODE_EDITOR'
but how to set it type to "compositing"?
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
If you mouse over the property you will see it is the
SpaceNodeEditor.tree_type property you want to set. The screen is split into areas, these areas have regions, toolbar header etc, and spaces. I've put a print statement in to show the spaces for the area. To get the space associated with an area use
context.space_data (after changing the
import bpy from bpy import context area = context.area area.type = 'NODE_EDITOR' # the context area is now a node editor # the space has the tree_type enum for sp in area.spaces: print(sp, sp.type, "has tree_treetype", hasattr(sp, "tree_type")) space = context.space_data # or better still space = area.spaces.active # set to compositing space.tree_type = 'CompositorNodeTree'
space.tree_type = 'CompositorNodeTree' run code above with
space.tree_type = 'Blah' which gives the options in the error message.
TypeError: bpy_struct: item.attr = val: enum "Blah" not found in ('ShaderNodeTree', 'CompositorNodeTree', 'TextureNodeTree')