[Bf-blender-cvs] [3cfcfb938db] geometry-nodes: Nodes: support creating geometry node groups

Jacques Lucke noreply at git.blender.org
Wed Oct 21 12:32:11 CEST 2020


Commit: 3cfcfb938dbef2d1e02014b336e0284d58dbb7f4
Author: Jacques Lucke
Date:   Wed Oct 21 12:32:02 2020 +0200
Branches: geometry-nodes
https://developer.blender.org/rB3cfcfb938dbef2d1e02014b336e0284d58dbb7f4

Nodes: support creating geometry node groups

===================================================================

M	release/scripts/startup/bl_operators/__init__.py
A	release/scripts/startup/bl_operators/geometry_nodes.py
M	release/scripts/startup/bl_ui/space_node.py

===================================================================

diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py
index c5baa659668..7682effaf41 100644
--- a/release/scripts/startup/bl_operators/__init__.py
+++ b/release/scripts/startup/bl_operators/__init__.py
@@ -31,6 +31,7 @@ _modules = [
     "console",
     "constraint",
     "file",
+    "geometry_nodes",
     "image",
     "mesh",
     "node",
diff --git a/release/scripts/startup/bl_operators/geometry_nodes.py b/release/scripts/startup/bl_operators/geometry_nodes.py
new file mode 100644
index 00000000000..0d43541e65c
--- /dev/null
+++ b/release/scripts/startup/bl_operators/geometry_nodes.py
@@ -0,0 +1,48 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+import bpy
+
+
+class NewGeometryNodeTree(bpy.types.Operator):
+    """Create a new geometry node tree"""
+
+    bl_idname = "node.new_geometry_node_tree"
+    bl_label = "New Geometry Node Tree"
+    bl_options = {'REGISTER', 'UNDO'}
+
+    @classmethod
+    def poll(cls, context):
+        return context.area.type == 'NODE_EDITOR' and context.space_data.tree_type == 'GeometryNodeTree'
+
+    def execute(self, context):
+        group = bpy.data.node_groups.new("Node Tree", 'GeometryNodeTree')
+        group.inputs.new('NodeSocketGeometry', "Geometry")
+        group.outputs.new('NodeSocketGeometry', "Geometry")
+        input_node = group.nodes.new('NodeGroupInput')
+        output_node = group.nodes.new('NodeGroupOutput')
+
+        input_node.location.x = -200 - input_node.width
+        output_node.location.x = 200
+        context.space_data.node_tree = group
+        return {'FINISHED'}
+
+
+classes = (
+    NewGeometryNodeTree,
+)
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index fca883eb466..4cd38831cdf 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -154,7 +154,7 @@ class NODE_HT_header(Header):
         elif snode.tree_type == 'GeometryNodeTree':
             NODE_MT_editor_menus.draw_collapsible(context, layout)
             layout.separator_spacer()
-            layout.template_ID(snode, "node_tree", new="node.new_node_tree")
+            layout.template_ID(snode, "node_tree", new="node.new_geometry_node_tree")
 
         else:
             # Custom node tree is edited as independent ID block



More information about the Bf-blender-cvs mailing list