Custom Properties: (embedded) NodeTree (such as material or compositing node_tree) Pointer Property not saving in Scene Property Group after re-opening file #122247

Open
opened 2024-05-25 05:56:40 +02:00 by Rodrigo Gama · 5 comments

System Information

  • Operating System: Windows 11
  • Graphics Card: RTX 4070 TI

Blender Version

  • Broken: 4.1.0, 40a5e739e2, blender-v4.1-release, 2024-03-25 20:42 (Also tested on 3.5, same results)

Short Description of the Error
NodeTree PointerProperty Not Saving in Scene Property Group after re-opening the file

Exact Steps to Reproduce the Error

  1. Register a scene custom PropertyGroup with a NodeTree PointerProperty:
import bpy
from bpy.utils import register_class

class MYADDON_AddonProps(bpy.types.PropertyGroup):
    node_tree_id: bpy.props.PointerProperty(
        type=bpy.types.NodeTree
    )
    
register_class(MYADDON_AddonProps)

bpy.types.Scene.my_addon_props = bpy.props.PointerProperty(
    type=MYADDON_AddonProps
)
  1. Store any NodeTree id_data in it:
bpy.context.scene.my_addon_props.node_tree_id = bpy.data.materials[1].node_tree
  1. Save and re-open the file. After re-opening, the PointerProperty loses the NodeTree reference.

Expected Behavior
The NodeTree reference should persist after saving and reopening the file.

Actual Behavior
The NodeTree reference is lost after reopening the file.

**System Information** - Operating System: Windows 11 - Graphics Card: RTX 4070 TI **Blender Version** - Broken: 4.1.0, 40a5e739e270, blender-v4.1-release, 2024-03-25 20:42 (Also tested on 3.5, same results) **Short Description of the Error** NodeTree PointerProperty Not Saving in Scene Property Group after re-opening the file **Exact Steps to Reproduce the Error** 1. Register a scene custom PropertyGroup with a NodeTree PointerProperty: ```python import bpy from bpy.utils import register_class class MYADDON_AddonProps(bpy.types.PropertyGroup): node_tree_id: bpy.props.PointerProperty( type=bpy.types.NodeTree ) register_class(MYADDON_AddonProps) bpy.types.Scene.my_addon_props = bpy.props.PointerProperty( type=MYADDON_AddonProps ) ``` 2. Store any NodeTree id_data in it: ```python bpy.context.scene.my_addon_props.node_tree_id = bpy.data.materials[1].node_tree ``` 3. Save and re-open the file. After re-opening, the PointerProperty loses the NodeTree reference. **Expected Behavior** The NodeTree reference should persist after saving and reopening the file. **Actual Behavior** The NodeTree reference is lost after reopening the file.
Rodrigo Gama added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2024-05-25 05:56:41 +02:00
TypeError: PointerProperty(...) expected an RNA type, failed with: RuntimeError: , missing bl_rna attribute from 'RNAMetaPropGroup' instance (may not be registered)

Error: Python: Traceback (most recent call last):
  File "\Text", line 8, in <module>
ValueError: bpy_struct "Scene" registration error: 'my_addon_props' PointerProperty could not register (see previous error)
TypeError: PointerProperty(...) expected an RNA type, failed with: RuntimeError: , missing bl_rna attribute from 'RNAMetaPropGroup' instance (may not be registered)

Error: Python: Traceback (most recent call last):
  File "\Text", line 8, in <module>
ValueError: bpy_struct "Scene" registration error: 'my_addon_props' PointerProperty could not register (see previous error)
TypeError: PointerProperty(...) expected an RNA type, failed with: RuntimeError: , missing bl_rna attribute from 'RNAMetaPropGroup' instance (may not be registered)

Error: Python: Traceback (most recent call last):
  File "\Text", line 8, in <module>
ValueError: bpy_struct "Scene" registration error: 'my_addon_props' PointerProperty could not register (see previous error)
``` TypeError: PointerProperty(...) expected an RNA type, failed with: RuntimeError: , missing bl_rna attribute from 'RNAMetaPropGroup' instance (may not be registered) Error: Python: Traceback (most recent call last): File "\Text", line 8, in <module> ValueError: bpy_struct "Scene" registration error: 'my_addon_props' PointerProperty could not register (see previous error) TypeError: PointerProperty(...) expected an RNA type, failed with: RuntimeError: , missing bl_rna attribute from 'RNAMetaPropGroup' instance (may not be registered) Error: Python: Traceback (most recent call last): File "\Text", line 8, in <module> ValueError: bpy_struct "Scene" registration error: 'my_addon_props' PointerProperty could not register (see previous error) TypeError: PointerProperty(...) expected an RNA type, failed with: RuntimeError: , missing bl_rna attribute from 'RNAMetaPropGroup' instance (may not be registered) Error: Python: Traceback (most recent call last): File "\Text", line 8, in <module> ValueError: bpy_struct "Scene" registration error: 'my_addon_props' PointerProperty could not register (see previous error) ```
Author

@mod_moder, I just updated the code snippet in the issue with the class registration, thank you.

@mod_moder, I just updated the code snippet in the issue with the class registration, thank you.
Member

I think this only works with "reusable" nodetrees, aka NodeGroups (the ones in bpy.data.node_groups)

A Material node_tree is not in main it seems (BKE_id_is_in_global_main) -- same is true for the "base" Compositing node_tree.

image

See also ntreeAddTreeEmbedded vs. ntreeAddTree

For "reusable" nodetrees, aka NodeGroups (the ones in bpy.data.node_groups), NodeTree Pointer Properties are kept correctly for me.

@mont29 : we might want to guard against setting such embedded nodetrees as Pointer Properties?

I think this only works with "reusable" nodetrees, aka NodeGroups (the ones in `bpy.data.node_groups`) A Material `node_tree` is not in main it seems (`BKE_id_is_in_global_main`) -- same is true for the "base" Compositing `node_tree`. ![image](/attachments/b0533e31-750c-4918-a617-8b4d35e31fdc) See also `ntreeAddTreeEmbedded` vs. `ntreeAddTree` For "reusable" nodetrees, aka NodeGroups (the ones in `bpy.data.node_groups`), NodeTree Pointer Properties are kept correctly for me. @mont29 : we might want to guard against setting such embedded nodetrees as Pointer Properties?
Philipp Oeser changed title from Custom Properties: NodeTree Pointer Property not saving in Scene Property Group after re-opening file to Custom Properties: (embedded) NodeTree (such as material or compositing node_tree) Pointer Property not saving in Scene Property Group after re-opening file 2024-05-27 14:50:38 +02:00
Member

Will confirm for now though, current behavior is misleading.

Will confirm for now though, current behavior is misleading.

We should indeed forbid assigning an embedded ID to an IDProperty... This is just not supported, embedded IDs are considered as 'private data' pwned by their regular ID owner.

Note that this also affects Scene' 'main' collection

We should indeed forbid assigning an embedded ID to an IDProperty... This is just not supported, embedded IDs are considered as 'private data' pwned by their regular ID owner. Note that this also affects Scene' 'main' collection
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 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#122247
No description provided.