Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/node_add_menu.py
| Show All 29 Lines | def draw_node_group_add_menu(context, layout): | ||||
| if node_tree in all_node_groups.values(): | if node_tree in all_node_groups.values(): | ||||
| layout.separator() | layout.separator() | ||||
| add_node_type(layout, "NodeGroupInput") | add_node_type(layout, "NodeGroupInput") | ||||
| add_node_type(layout, "NodeGroupOutput") | add_node_type(layout, "NodeGroupOutput") | ||||
| if node_tree: | if node_tree: | ||||
| from nodeitems_builtins import node_tree_group_type | from nodeitems_builtins import node_tree_group_type | ||||
| def contains_group(nodetree, group): | |||||
| if nodetree == group: | |||||
| return True | |||||
| for node in nodetree.nodes: | |||||
| if node.bl_idname in node_tree_group_type.values() and node.node_tree is not None: | |||||
| if contains_group(node.node_tree, group): | |||||
| return True | |||||
| return False | |||||
| groups = [ | groups = [ | ||||
| group for group in context.blend_data.node_groups | group for group in context.blend_data.node_groups | ||||
| if (group.bl_idname == node_tree.bl_idname and | if (group.bl_idname == node_tree.bl_idname and | ||||
| not contains_group(group, node_tree) and | not group.contains_recursive(node_tree) and | ||||
| not group.name.startswith('.')) | not group.name.startswith('.')) | ||||
| ] | ] | ||||
| if groups: | if groups: | ||||
| layout.separator() | layout.separator() | ||||
| for group in groups: | for group in groups: | ||||
| props = add_node_type(layout, node_tree_group_type[group.bl_idname], label=group.name) | props = add_node_type(layout, node_tree_group_type[group.bl_idname], label=group.name) | ||||
| ops = props.settings.add() | ops = props.settings.add() | ||||
| ops.name = "node_tree" | ops.name = "node_tree" | ||||
| Show All 18 Lines | |||||