path_from_id does not work on subproperties of a custom node #51096

Closed
opened 2017-03-31 12:04:07 +02:00 by Jacques Lucke · 5 comments
Member

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):
        print(self.path_from_id("prop"))
    
bpy.utils.register_class(MyPropGroup)
    
class MyNode(bpy.types.Node):
    bl_idname = "MyNode"
    bl_label = "My Node"
    
    prop = BoolProperty()
    subprop = PointerProperty(type = MyPropGroup)
    
    def test(self):
        print(self.path_from_id("prop"))
    
bpy.utils.register_class(MyNodeTree)
bpy.utils.register_class(MyNode)

tree = bpy.data.node_groups.new("Test Tree", "MyNodeTree")
node = tree.nodes.new("MyNode")

node.test()
node.subprop.test()
**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): print(self.path_from_id("prop")) bpy.utils.register_class(MyPropGroup) class MyNode(bpy.types.Node): bl_idname = "MyNode" bl_label = "My Node" prop = BoolProperty() subprop = PointerProperty(type = MyPropGroup) def test(self): print(self.path_from_id("prop")) bpy.utils.register_class(MyNodeTree) bpy.utils.register_class(MyNode) tree = bpy.data.node_groups.new("Test Tree", "MyNodeTree") node = tree.nodes.new("MyNode") node.test() node.subprop.test() ```
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke

Added subscriber: @Sergey

Added subscriber: @Sergey

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sergey Sharybin self-assigned this 2017-06-09 11:29:47 +02:00

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.

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.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#51096
No description provided.