Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-10-21 13:32:02 +0300
committerJacques Lucke <jacques@blender.org>2020-10-21 13:32:02 +0300
commit3cfcfb938dbef2d1e02014b336e0284d58dbb7f4 (patch)
tree5f8a3c711d6e8431aa6116ddf60ad3e0ec4d0411 /release
parentbcdc6910a0489620f08195d78db5589ed701ca3d (diff)
Nodes: support creating geometry node groups
Diffstat (limited to 'release')
-rw-r--r--release/scripts/startup/bl_operators/__init__.py1
-rw-r--r--release/scripts/startup/bl_operators/geometry_nodes.py48
-rw-r--r--release/scripts/startup/bl_ui/space_node.py2
3 files changed, 50 insertions, 1 deletions
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