diff options
Diffstat (limited to 'release/scripts/templates_py/custom_nodes.py')
-rw-r--r-- | release/scripts/templates_py/custom_nodes.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/release/scripts/templates_py/custom_nodes.py b/release/scripts/templates_py/custom_nodes.py index bf89c0debad..992ef734859 100644 --- a/release/scripts/templates_py/custom_nodes.py +++ b/release/scripts/templates_py/custom_nodes.py @@ -49,13 +49,15 @@ class MyCustomSocket(NodeSocket): def draw_color(self, context, node): return (1.0, 0.4, 0.216, 0.5) + # Mix-in class for all custom nodes in this tree type. # Defines a poll function to enable instantiation. -class MyCustomTreeNode : +class MyCustomTreeNode: @classmethod def poll(cls, ntree): return ntree.bl_idname == 'CustomTreeType' + # Derived from the Node base type. class MyCustomNode(Node, MyCustomTreeNode): # === Basics === @@ -123,6 +125,7 @@ class MyCustomNode(Node, MyCustomTreeNode): import nodeitems_utils from nodeitems_utils import NodeCategory, NodeItem + # our own base class with an appropriate poll function, # so the categories only show up in our own tree type class MyNodeCategory(NodeCategory): @@ -143,12 +146,12 @@ node_categories = [ # NB: settings values are stored as string expressions, # for this reason they should be converted to strings using repr() NodeItem("CustomNodeType", label="Node A", settings={ - "myStringProperty" : repr("Lorem ipsum dolor sit amet"), - "myFloatProperty" : repr(1.0), + "myStringProperty": repr("Lorem ipsum dolor sit amet"), + "myFloatProperty": repr(1.0), }), NodeItem("CustomNodeType", label="Node B", settings={ - "myStringProperty" : repr("consectetur adipisicing elit"), - "myFloatProperty" : repr(2.0), + "myStringProperty": repr("consectetur adipisicing elit"), + "myFloatProperty": repr(2.0), }), ]), ] |