I've done a fair amount of custom PyNode tree scripting for Sverchok, but one thing remains a bit nebulous and i'm hoping someone can shed some light.
The Material node trees have this Group feature which turns the background green and enables an operator on the header to call bpy.ops.node.tree_path_parent() to go to the parent node tree.
The poll / execute code for bpy.ops.node.tree_path_parent() is (...full code link)
@classmethod
def poll(cls, context):
space = context.space_data
# needs active node editor and a tree
return (space.type == 'NODE_EDITOR' and len(space.path) > 1)
def execute(self, context):
space = context.space_data
space.path.pop()
return {'FINISHED'}
For a NodeGroup of ShaderNodeTree space.path becomes a collection of 2 paths.
<bpy_collection[2], SpaceNodeEditorPath>
--- <bpy_struct, ShaderNodeTree("Shader Nodetree")>
--- <bpy_struct, ShaderNodeTree("NodeGroup")>
My simple attempt at declaring a NodeCustomGroup has some superficial success.
My question is how / where can I set the space.path so there's something to .pop(), -- somewhere in the init of the custom node?
excerpt full code here:
class SvGroupNodeExp(bpy.types.NodeCustomGroup, SverchCustomTreeNode):
bl_idname = 'SvGroupNodeExp'
bl_label = 'Group Exp'
bl_icon = 'OUTLINER_OB_EMPTY'
group_name = StringProperty()
def init(self, context):
self.node_tree = bpy.data.node_groups.new('nooobgroup', 'SverchCustomTreeType')
self.group_name = self.node_tree.name
# self.node_tree.parent = self
# space = context.space_data
nodes = self.node_tree.nodes
inputnode = nodes.new('SvGroupInputsNode')
outputnode = nodes.new('SvGroupOutputsNode')
inputnode.location = (-300, 0)
outputnode.location = (300, 0)


bpy.ops.node.group_edit()? – sambler Jul 26 '16 at 08:11back_to_parentoperator.. – zeffii Jul 26 '16 at 09:12space.path. Not sure we can use the existing menu entries but we can use the same shortcuts to run the custom operators. – sambler Jul 26 '16 at 13:36