Can not get eval obj's attribute in get/set function #99964

Closed
opened 2022-07-25 12:35:40 +02:00 by yonghao lv · 30 comments

System Information
Operating system: Windows-10-10.0.22000-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2080 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 512.96

Blender Version
Broken: version: 3.3.0 Alpha, branch: master, commit date: 2022-07-24 19:33, hash: 6db059e3d7
Worked: 3.2.1 / 3.3.0 7-10 build

Short description of error
2022-07-25 18-23-39.mp4

when using this script to get object's attribute in a property's get/set function, it didn't work

def get_mesh_obj_attrs(context, obj, deps=None) -> dict:
    """

    :param obj:bpy.types.Object
    :param attr:
    :return:list
    """
    attr_dict = dict()

    depsg_eval = deps if deps else context.evaluated_depsgraph_get()  # deps 由外部传入,防止冻结
    depsg_eval.update()
    obj_eval = obj.evaluated_get(depsg_eval)

    for name, attr in obj_eval.data.attributes.items():
        attr_data = attr.data
        attr_dict[name] = [v.value for v in attr_data.values()]

    print(attr_dict)

    return attr_dict

Exact steps for others to reproduce the error
I need some time to clean up the code and upload the smallest file

**System Information** Operating system: Windows-10-10.0.22000-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 2080 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 512.96 **Blender Version** Broken: version: 3.3.0 Alpha, branch: master, commit date: 2022-07-24 19:33, hash: `6db059e3d7` Worked: 3.2.1 / 3.3.0 7-10 build **Short description of error** [2022-07-25 18-23-39.mp4](https://archive.blender.org/developer/F13314736/2022-07-25_18-23-39.mp4) when using this script to get object's attribute in a property's get/set function, it didn't work ``` def get_mesh_obj_attrs(context, obj, deps=None) -> dict: """ :param obj:bpy.types.Object :param attr: :return:list """ attr_dict = dict() depsg_eval = deps if deps else context.evaluated_depsgraph_get() # deps 由外部传入,防止冻结 depsg_eval.update() obj_eval = obj.evaluated_get(depsg_eval) for name, attr in obj_eval.data.attributes.items(): attr_data = attr.data attr_dict[name] = [v.value for v in attr_data.values()] print(attr_dict) return attr_dict ``` **Exact steps for others to reproduce the error** I need some time to clean up the code and upload the smallest file
Author

Added subscriber: @1029910278

Added subscriber: @1029910278

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

Thanks for the report, but in order to forward it to the developers, we need a reliable way to reproduce the issue.

So please provide a simple .blend file or script showing the problem.

A guideline for making a good bug report can be found at https://wiki.blender.org/wiki/Process/Bug_Reports

Thanks for the report, but in order to forward it to the developers, we need a reliable way to reproduce the issue. So please provide a simple .blend file or script showing the problem. A guideline for making a good bug report can be found at https://wiki.blender.org/wiki/Process/Bug_Reports
Author

The first test file from my code. I am not sure it cause this error directly, it work fine in my addon but crash blender when select a object(to read its attribute) here
ERROR (bpy.rna): C:\Users\blender\git\blender-vdev\blender.git\source\blender\python\intern\bpy_rna.c:7392 pyrna_srna_Subtype: failed to register 'Attribute'

Reproduce

  1. run the script
  2. select the last mesh object
    get_geo_obj_attr.blend
    get_geo_obj_attr.crash.txt

I will write a get/set examle later

The first test file from my code. I am not sure it cause this error directly, it work fine in my addon but crash blender when select a object(to read its attribute) here `ERROR (bpy.rna): C:\Users\blender\git\blender-vdev\blender.git\source\blender\python\intern\bpy_rna.c:7392 pyrna_srna_Subtype: failed to register 'Attribute'` Reproduce 1. run the script 2. select the last mesh object [get_geo_obj_attr.blend](https://archive.blender.org/developer/F13321214/get_geo_obj_attr.blend) [get_geo_obj_attr.crash.txt](https://archive.blender.org/developer/F13321215/get_geo_obj_attr.crash.txt) I will write a get/set examle later
Author

The second file, this is how it work get_geo_obj_attr2.blend

  1. run the script
  2. go to console to slide the test value
  3. select the 'Cube', you can see its value print in console
  4. select the 'Cube.001' who reference from a curve object , it will not get the attribute in console (nodegroup: transfrom attribute from curve to mesh by index, it works well in 3.2)

PS: I set the depsgragh to a global value becauese I found that if I call 2 context.eval_depsgraph_get at a same time will freeze blender forver (like 2 drawing function call at the same time)

The second file, this is how it work [get_geo_obj_attr2.blend](https://archive.blender.org/developer/F13321385/get_geo_obj_attr2.blend) 1. run the script 2. go to console to slide the test value 3. select the 'Cube', you can see its value print in console 4. select the 'Cube.001' who reference from a curve object , it will not get the attribute in console (nodegroup: transfrom attribute from curve to mesh by index, it works well in 3.2) PS: I set the depsgragh to a global value becauese I found that if I call 2 context.eval_depsgraph_get at a same time will freeze blender forver (like 2 drawing function call at the same time)

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'
Member

Added subscriber: @OmarEmaraDev

Added subscriber: @OmarEmaraDev
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

In your second file, if I connect the Domain Size node to the bezier curve geometry output, it prints the attributes as expected. Could this be the issue or was this just a mistake while preparing the file?

Regardless, I don't think using with contexts and depsgraphs in RNA setter and getter functions is safe.

In your second file, if I connect the Domain Size node to the bezier curve geometry output, it prints the attributes as expected. Could this be the issue or was this just a mistake while preparing the file? Regardless, I don't think using with contexts and depsgraphs in RNA setter and getter functions is safe.
Author

oh, maybe I shound check the file again. I will check it out asap

oh, maybe I shound check the file again. I will check it out asap
Author

Is there an other to get attribute generated from geo node attribute without using depsgraphs?

Is there an other to get attribute generated from geo node attribute without using depsgraphs?
Author

In #99964#1398428, @OmarEmaraDev wrote:
In your second file, if I connect the Domain Size node to the bezier curve geometry output, it prints the attributes as expected. Could this be the issue or was this just a mistake while preparing the file?

Regardless, I don't think using with contexts and depsgraphs in RNA setter and getter functions is safe.

Yes, It need to link to the output. It was a mistake sorry.
I found the true problem is the obj must be link to the scene so that it can print attribute in 3.3/3.4(It didn't to link to the scene in 3.2)

3.4 with obj unlink
image.png

3.4 with obj link
image.png

> In #99964#1398428, @OmarEmaraDev wrote: > In your second file, if I connect the Domain Size node to the bezier curve geometry output, it prints the attributes as expected. Could this be the issue or was this just a mistake while preparing the file? > > Regardless, I don't think using with contexts and depsgraphs in RNA setter and getter functions is safe. Yes, It need to link to the output. It was a mistake sorry. I found the true problem is the obj must be link to the scene so that it can print attribute in 3.3/3.4(It didn't to link to the scene in 3.2) 3.4 with obj unlink ![image.png](https://archive.blender.org/developer/F13338504/image.png) 3.4 with obj link ![image.png](https://archive.blender.org/developer/F13338510/image.png)
Member

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

Can you clarify your last point? Which object wasn't linked to the scene? The one named Motion Control-MotionPath? Is that in the second file you shared?

Can you clarify your last point? Which object wasn't linked to the scene? The one named `Motion Control-MotionPath`? Is that in the second file you shared?
Author
[get_geo_obj_attr2 (1).blend1](https://archive.blender.org/developer/F13396671/get_geo_obj_attr2__1_.blend1) upload again
Member

I still don't understand the issue. It prints {'factor': [0.0, 0.9999999403953552], 'length': [0.0, 0.0]} for me when Cube.001 is selected, which means the attributes are correctly retrieved.

Can you clarify this?

Can you clarify your last point? Which object wasn't linked to the scene? The one named Motion Control-MotionPath? Is that in the second file you shared?

I still don't understand the issue. It prints `{'factor': [0.0, 0.9999999403953552], 'length': [0.0, 0.0]}` for me when `Cube.001` is selected, which means the attributes are correctly retrieved. Can you clarify this? > Can you clarify your last point? Which object wasn't linked to the scene? The one named `Motion Control-MotionPath`? Is that in the second file you shared?
Author

In #99964#1405126, @OmarEmaraDev wrote:
I still don't understand the issue. It prints {'factor': [0.0, 0.9999999403953552], 'length': [0.0, 0.0]} for me when Cube.001 is selected, which means the attributes are correctly retrieved.

Can you clarify this?

Can you clarify your last point? Which object wasn't linked to the scene? The one named Motion Control-MotionPath? Is that in the second file you shared?

check this file get_geo_obj_attr2 (1).blend1 and run the script
Problem: in 3.2 and early 3.3 , attribute can be printed while the object is not linked to the scene, but in later 3,3 and 3.4 , object must be linked to the scene so that the attribute can be printed

> In #99964#1405126, @OmarEmaraDev wrote: > I still don't understand the issue. It prints `{'factor': [0.0, 0.9999999403953552], 'length': [0.0, 0.0]}` for me when `Cube.001` is selected, which means the attributes are correctly retrieved. > > Can you clarify this? > >> Can you clarify your last point? Which object wasn't linked to the scene? The one named `Motion Control-MotionPath`? Is that in the second file you shared? check this file [get_geo_obj_attr2 (1).blend1](https://archive.blender.org/developer/F13396671/get_geo_obj_attr2__1_.blend1) and run the script Problem: in 3.2 and early 3.3 , attribute can be printed while the object is not linked to the scene, but in later 3,3 and 3.4 , object must be linked to the scene so that the attribute can be printed
Member

I suspect the 3.3/3.4 behavior is the more correct one, since unlinked objects will not be evaluated because they don't affect anything. So wouldn't this be expected?
What is the use case for evaluating an unlinked object?

I suspect the 3.3/3.4 behavior is the more correct one, since unlinked objects will not be evaluated because they don't affect anything. So wouldn't this be expected? What is the use case for evaluating an unlinked object?
Author

So what I expect is I can read bpy.data.objects's attributes without linking them to the scene. If we can read their location, we shounld be able to read their attirbute.
Seems now the deps graph no longer consider the object not link to the scene?

So what I expect is I can read bpy.data.objects's attributes without linking them to the scene. If we can read their location, we shounld be able to read their attirbute. Seems now the deps graph no longer consider the object not link to the scene?
Member

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

Situation is unclear for me.

In #99964#1406179, @1029910278 wrote:
check this file get_geo_obj_attr2 (1).blend1 and run the script
Problem: in 3.2 and early 3.3 , attribute can be printed while the object is not linked to the scene, but in later 3,3 and 3.4 , object must be linked to the scene so that the attribute can be printed

I dont see a difference in 3.2 vs. master, selecting Cube.001 after running the script and changing the test_value will equally print an empty dict {}
What am I doing wrong?

Situation is unclear for me. > In #99964#1406179, @1029910278 wrote: > check this file [get_geo_obj_attr2 (1).blend1](https://archive.blender.org/developer/F13396671/get_geo_obj_attr2__1_.blend1) and run the script > Problem: in 3.2 and early 3.3 , attribute can be printed while the object is not linked to the scene, but in later 3,3 and 3.4 , object must be linked to the scene so that the attribute can be printed I dont see a difference in 3.2 vs. master, selecting `Cube.001` after running the script and changing the test_value will equally print an empty dict {} What am I doing wrong?
Member

poke ^

poke ^
Author

sorry, busy for moving house last week. I will give an respond tomorrow

sorry, busy for moving house last week. I will give an respond tomorrow
Member

one more poke ^

one more poke ^
Member

Changed status from 'Needs User Info' to: 'Archived'

Changed status from 'Needs User Info' to: 'Archived'
Member

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed.

Thanks again for the report. If the problem persists please open a new report with the required information.

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed. Thanks again for the report. If the problem persists please open a new report with the required information.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
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#99964
No description provided.