I was experimenting with python scripting and came across registering addons. According to Blender Add-on Tutorial, the register and unregister functions are called when activating and deactivating the addon. I tried this but it seemed that the register function is ignored during activation! Register Function Ignored

To replicate, copy following script and save it into the addons folder.

bl_info = {
    "name": "Example",
    "category": "Node",
    "location": "Node Editor",
import bpy
from bpy.types import NodeTree, Node, NodeSocket
import nodeitems_utils
from nodeitems_utils import NodeItem, NodeCategory

class MyCustomTree(NodeTree):
    bl_idname = 'CustomTreeType'
    bl_label = "Custom Node Tree"
    bl_icon = 'NODETREE'

class MyCustomSocket(NodeSocket):
    bl_idname = 'CustomSocketType'
    bl_label = "Custom Node Socket"

    my_items = (
        ('DOWN', "Down", "Where your feet are"),
        ('UP', "Up", "Where your head should be"),
        ('LEFT', "Left", "Not right"),
        ('RIGHT', "Right", "Not left"),

    my_enum_prop: bpy.props.EnumProperty(
        description="Just an example",

    def draw(self, context, layout, node, text):
        if self.is_output or self.is_linked:
            layout.prop(self, "my_enum_prop", text=text)

    def draw_color(self, context, node):
        return (1.0, 0.4, 0.216, 0.5)

class MyCustomTreeNode:
    def poll(cls, ntree):
        return ntree.bl_idname == 'CustomTreeType'

class MyCustomNode(MyCustomTreeNode, Node):
    bl_idname = 'CustomNodeType'
    bl_label = "Custom Node"

    my_string_prop: bpy.props.StringProperty()
    my_float_prop: bpy.props.FloatProperty(default=3.1415926)

    def init(self, context):
        self.inputs.new('CustomSocketType', "Hello")
        self.inputs.new('NodeSocketFloat', "World")
        self.inputs.new('NodeSocketVector', "!")

        self.outputs.new('NodeSocketColor', "How")
        self.outputs.new('NodeSocketColor', "are")
        self.outputs.new('NodeSocketFloat', "you")

    def draw_buttons(self, context, layout):
        layout.label(text="Node settings")
        layout.prop(self, "my_float_prop")

    def draw_buttons_ext(self, context, layout):
        layout.prop(self, "my_float_prop")
        layout.prop(self, "my_string_prop")

    def draw_label(self):
        return "Example"

class MyNodeCategory(NodeCategory):
    def poll(cls, context):
        return context.space_data.tree_type == 'CustomTreeType'

node_categories = [
    MyNodeCategory('SOMENODES', "Some Nodes", items=[
    MyNodeCategory('OTHERNODES', "Other Nodes", items=[
        NodeItem("CustomNodeType", label="Node A", settings={
            "my_string_prop": repr("Lorem ipsum dolor sit amet"),
            "my_float_prop": repr(1.0),
        NodeItem("CustomNodeType", label="Node B", settings={
            "my_string_prop": repr("consectetur adipisicing elit"),
            "my_float_prop": repr(2.0),

classes = (

def register():
    from bpy.utils import register_class
    for cls in classes:

    nodeitems_utils.register_node_categories('CUSTOM_NODES', node_categories)

def unregister():

    from bpy.utils import unregister_class
    for cls in reversed(classes):

if __name__ == "__main__":

To determine the success of the addon, after activation, there should be a "Custom Node Tree" editor.

  • $\begingroup$ Hello and welcome to BSE! Did you try the simplest example addon they presented? Did that also not work? I tried the simplest example they gave and it works. Also please share the script (not as screenshot) you are using so we can test it. $\endgroup$ Sep 13 at 2:34
  • $\begingroup$ In other former personal tests, leaving out the register function would raise an error message during activation. But surprising for this one, though the register function is commented out, it raises no single error message. Having or omitting the register function seem to not make any difference. $\endgroup$ Sep 13 at 3:27
  • 2
    $\begingroup$ can you share a minimal reproducible addon code for this problem? or else we can't really help. $\endgroup$ Sep 13 at 3:32
  • 1
    $\begingroup$ Hi, @BlenderEnthusiast Please cut and paste your code in to an edit of your question.. It will be much easier for folks to help you out. $\endgroup$
    – Robin Betts
    Sep 13 at 17:49

2 Answers 2


If you execute the code you provided from the text editor, you get the error:

Python: Traceback (most recent call last):
  File "\Text", line 121, in <module>
  File "\Text", line 109, in register
NameError: name 'nodeitems_utils' is not defined

Line 109:

nodeitems_utils.register_node_categories('CUSTOM_NODES', node_categories)

nodeitems_utils isn't present in your imports:

import bpy
from bpy.types import NodeTree, Node, NodeSocket
from nodeitems_utils import NodeItem, NodeCategory

You could import the node categories' register/unregisters there and remove nodeitems_utils. when you register/unregister them to make that error go away, and it seems to also unregister when disabling the addon.

import bpy
from bpy.types import NodeTree, Node, NodeSocket
from nodeitems_utils import NodeItem, NodeCategory, register_node_categories, unregister_node_categories


def register():
    register_node_categories('CUSTOM_NODES', node_categories)

def unregister():

But i am not familiar with custom nodes, so I don't know what your script does and how to check its success beyond that.

  • $\begingroup$ my apologies, just a replication error. The error has nothing to do with the real problem. I have fixed the script, so try again. $\endgroup$ Sep 13 at 22:29

It turns out the blender field should be included in the bl_info dictionary. Otherwise, Blender will just ignore the script. the bl_info should end-up looking like this:

bl_info: {
    "name": "Example",
    "category": "Node",
    "blender": (3,40,0)

def register()

def unregister()

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .