path_from_id does not work on subproperties of a custom node
Closed, ArchivedPublic


System Information
Windows 10, 64 bit

Blender Version
Broken: 7cb2974

Short description of error
I want to create a subproperty (Pointer/Collection) in my custom node. Inside I want to declare a property with an update function that somehow knows the parent node.
I found that I could use the path_from_id function and do some string manipulation to access the node. Beside that being not a very nice solution, it even does not seem to work.

I also tested registering subproperties in a Scene, there the path_from_id function works properly. In my custom node I get an error message with "found but does not support path creation". I can't really see if this is intended, a bug or just something that is not implemented yet.

Exact steps for others to reproduce the error

Here is a little test script that raises the exception:

import bpy
from bpy.props import *

class MyNodeTree(bpy.types.NodeTree):
    bl_idname = "MyNodeTree"
    bl_label = "My Node Tree"
    bl_icon = "COPY_ID"
class MyPropGroup(bpy.types.PropertyGroup):
    prop = BoolProperty()
    def test(self):
class MyNode(bpy.types.Node):
    bl_idname = "MyNode"
    bl_label = "My Node"
    prop = BoolProperty()
    subprop = PointerProperty(type = MyPropGroup)
    def test(self):

tree ="Test Tree", "MyNodeTree")
node ="MyNode")



Sergey Sharybin (sergey) closed this task as Archived.Jun 9 2017, 11:29 AM
Sergey Sharybin (sergey) claimed this task.

This is a design limitation: you can never go from current property to parent, it is just unknown. So what happens here is that path_from_id() can find property, but can not construct full path to it relative to ID because you don't know where it is coming from.

In Blender side we are working this around by providing special path functions to properties, which are iterating over all possible parents and gives path to the parent which actually hold the property. This is crappy, but it is barely used. but because this is stupid,. it is not exposed to Python API.

So thanks for the report, but it's just known design limitation.