I'm trying to register a PointerProperty to a node in a material's node tree.
After hours of trying a number of things, I suspect this is impossible and I think it's related to nodes not having their own bpy.data entry.
Basically I want to avoid having to repeatedly iterate over the nodes of a materials's node tree. So, once I found my node, I want to store in a PointerProperty.
I'm doing something similar with certain objects:
myobj = PointerProperty(name="My Obj", type=bpy.types.Object)
Which allows me to assign an object like so:
bpy.data.objects.MyPropGroup.myobj = bpy.data.objects
And access the object like this:
bpy.data.objects.MyPropGroup.myobj.select = False bpy.data.objects.MyPropGroup.myobj.hide_render = True
So far so good. I'd like to do the same with nodes, set the property like so
bpy.data.materials.MyPropGroup.mynode = bpy.data.materials.node_tree.nodes['MyNode']
And access it like this:
bpy.data.materials.MyPropGroup.mynode.mute = True
Unfortunately, all my attempts to register the pointer failed. I've tried these and a buch more.
mynode = PointerProperty(name="My Node", type=bpy.types.Node) mynode = PointerProperty(name="My Node", type=bpy.types.NodeGroup) mynode = PointerProperty(name="My Node", type=bpy.types.ShaderNode) mynode = PointerProperty(name="My Node", type=bpy.types.ShaderNodeGroup)
All of them failed with
ValueError: bpy_struct "MyPropertyGroup" registration error: mynode could not register
It is acually a node group I am trying to point to, but would hope to do it for other node types as well.
I've succeeded registering
mynode = PointerProperty(name="My Node", type=bpy.types.ShaderNodeTree)
Which I then can assign the group node to. However I can't access it to manipulate node properties (like mute for instance). I can only access the group node tree of the group.
Any pointers - no pun intended - are appreciated. Although I could select the node group in question by name, instead of iterating over the node tree, I'd like to avoid it.