CustomNodes New Tree always named 'NodeTree' even for multiple and different Add-ons

Looks like I’ve hit the ‘this is not a bug’ wall :man_facepalming:t4:

Is a very dangerous inconsistency with Blender own behaviour that will break third party addon not aware of the misbehaviour.

Can someone give me a hand finding to whom I need to report this so is fixed?

Thanks in advance,

1 Like

There’s no one else to report this to, the policy for such reports is what it is. But you can contribute a patch to improve the behavior.

1 Like

If I had the knowledge, be sure Ill do it. :roll_eyes:

But so far I can navigate Blender Source code to find the ‘right’ way to do things with the Python API. :man_shrugging:t4:



Maybe someone can give me a little help. I’ve spent the last 10 days looking to this problem.
I found where the code is doing the creation of a Node Tree and why it doesn’t respect the bl_idname defined in the CustomNode class.

Im using my own compilation of Blender in Windows so I found it

Line 164:
            # Custom node tree is edited as independent ID block
            NODE_MT_editor_menus.draw_collapsible(context, layout)

            layout.template_ID(snode, "node_tree", new="node.new_node_tree")

The template_ID function doesnt allow to pass parameters to the node.new_node_tree operator.
I’ve tried everything I could thiink and couldn’t make it work with template_ID.

This will partially work (I’ve tested it):

layout.operator('node.new_node_tree', text='+ New').name = snode.tree_type

But loses the dropdown selector for trees due to the lack of template ID creating it.

In this same file, line 143 we can see how Geometry Nodes does it. And it is using a customized operator for it.

I kept digging in Blender Source Code and found the node.new_node_tree code operator in :

Line 826:
static int new_node_tree_exec(bContext *C, wmOperator *op)

The operator expects two properties ‘type’ and ‘name’.
If type is passed a value it searches for this type and uses it as the tree type of the new node tree.
If type has no value uses the Node Editor Space tree_idname as the tree type of the new node tree…

If name is passed a value uses it as the name of the of the new node tree.
If not uses and translates the string ‘NodeTree’.

And that is the problem.
The operator should check if the passed type, or the Node Editor Space tree_idname is one of the Blender internal types, including Geometry Nodes. Or if it’s any other type get the bl_idname property of the class if defined or the name class insted as the new tree name.

What kind of modification will be better so it can be accepted as a patch?

  • Do the change on this operator.
  • Modify the to search for a new operator called ‘node.new_’ + CustomNode.bl_idname or the CustomNode.class if bl_idname is not defined.
    This option will force that the CustomNodes template show how to create such operator.

0 voters

I will try to locate the authors of other CustomNodes addons and point them here so the can give their opinon.



I voted for the second option because I think there is no need to change the C operator, and is similar to what Geometry Nodes is doing.


1 Like

I don’t have anything really to add on the actual topic. Just wanted to say: keep up the good work! :wink: That’s all.