diff options
author | Angus Stanton <abstanton> | 2021-03-19 13:20:57 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-03-19 13:24:27 +0300 |
commit | ae650b016f760b103670b3d2f3a18d150cd05ce5 (patch) | |
tree | dd4d50493e9457bf12651191c2141501315aded1 | |
parent | de296e842932a1d746bfa4bc4f3e7e9cbf7fbf4b (diff) |
Fix T86208: copy node group button is inconsistent in geometry nodes
Differential Revision: https://developer.blender.org/D10740
-rw-r--r-- | release/scripts/startup/bl_operators/geometry_nodes.py | 25 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_node.py | 5 |
2 files changed, 29 insertions, 1 deletions
diff --git a/release/scripts/startup/bl_operators/geometry_nodes.py b/release/scripts/startup/bl_operators/geometry_nodes.py index 4ced3cb5957..0e7f8b7b1e7 100644 --- a/release/scripts/startup/bl_operators/geometry_nodes.py +++ b/release/scripts/startup/bl_operators/geometry_nodes.py @@ -91,7 +91,32 @@ class NewGeometryNodeTreeAssign(bpy.types.Operator): return {'FINISHED'} +class CopyGeometryNodeTreeAssign(bpy.types.Operator): + """Copy the active geometry node group and assign it to the active modifier""" + + bl_idname = "node.copy_geometry_node_group_assign" + bl_label = "Copy Geometry Node Group" + bl_options = {'REGISTER', 'UNDO'} + + @classmethod + def poll(cls, context): + return geometry_modifier_poll(context) + + def execute(self, context): + modifier = context.object.modifiers.active + if modifier is None: + return {'CANCELLED'} + + group = modifier.node_group + if group is None: + return {'CANCELLED'} + + modifier.node_group = group.copy() + return {'FINISHED'} + + classes = ( NewGeometryNodesModifier, NewGeometryNodeTreeAssign, + CopyGeometryNodeTreeAssign, ) diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 7f66cdd3d74..b6fbb840fab 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -164,7 +164,10 @@ class NODE_HT_header(Header): elif ob: active_modifier = ob.modifiers.active if active_modifier and active_modifier.type == "NODES": - row.template_ID(active_modifier, "node_group", new="node.new_geometry_node_group_assign") + if active_modifier.node_group: + row.template_ID(active_modifier, "node_group", new="node.copy_geometry_node_group_assign") + else: + row.template_ID(active_modifier, "node_group", new="node.new_geometry_node_group_assign") else: row.template_ID(snode, "node_tree", new="node.new_geometry_nodes_modifier") |