AttributeGroup API: "active" is meaningless (always refers to all attributes, not the specific AttributeGroup) -- e.g. mesh.color_attributes.active #107194

Open
opened 2023-04-20 21:14:33 +02:00 by Scurest · 13 comments
Contributor

Blender Version
Broken: blender-3.5.1-candidate+v35.eaf13ebc6776-linux.x86_64-release
Worked: blender-3.3.6-stable+v33.948f8298b982-linux.x86_64-release

Short description of error
Accessing the active color attribute through mesh.color_attributes.active returns mesh.attributes["position"] instead.

API is basically broken since eae36be372
the particular example in this report was exposed by 1af62cb3bf

Exact steps for others to reproduce the error

  1. Create a new cube.
  2. Open Python Console and do:
>>> C.object.data.color_attributes.active
bpy.data.meshes['Cube'].attributes["position"]
  1. Try the same thing in 3.3. It correctly returns None.
**Blender Version** Broken: blender-3.5.1-candidate+v35.eaf13ebc6776-linux.x86_64-release Worked: blender-3.3.6-stable+v33.948f8298b982-linux.x86_64-release **Short description of error** Accessing the active color attribute through `mesh.color_attributes.active` returns `mesh.attributes["position"]` instead. API is basically broken since eae36be372 the particular example in this report was exposed by 1af62cb3bf **Exact steps for others to reproduce the error** 1. Create a new cube. 2. Open Python Console and do: ```Py >>> C.object.data.color_attributes.active bpy.data.meshes['Cube'].attributes["position"] ``` 3. Try the same thing in 3.3. It correctly returns `None`.
Scurest added the
Severity
Normal
Type
Report
Status
Needs Triage
labels 2023-04-20 21:14:34 +02:00
Author
Contributor

Also if you create a color attribute by going into Vertex Paint mode, it will still incorrectly return attributes["position"]. If you create a color attribute by going through the Properties editor however, it behaves correctly.

Also if you create a color attribute by going into Vertex Paint mode, it will still incorrectly return `attributes["position"]`. If you create a color attribute by going through the Properties editor however, it behaves correctly.
Member

Hi, thanks for the report. I can confirm. Checking...

Hi, thanks for the report. I can confirm. Checking...
Pratik Borhade added
Module
Python API
Status
Confirmed
Interest
Modeling
and removed
Status
Needs Triage
labels 2023-04-21 07:01:10 +02:00
Member
Caused by 1af62cb3bf46f0cd328ab0840a1363eca938c628 @HooglyBoogly ^
Pratik Borhade added
Severity
High
and removed
Severity
Normal
labels 2023-04-21 07:43:00 +02:00
Pratik Borhade changed title from Python: wrong mesh.color_attributes.active to Regression: Python: wrong mesh.color_attributes.active 2023-04-21 07:43:07 +02:00

I can have a look, have been busy in this area.

I can have a look, have been busy in this area.
Member

Note: even in 3.3, the logic is wrong.
color_attributes.active will always return the active attribute (no matter if color or not).
It just happens to be that in 3.3, there is no real attribute there yet on the default cube

Same seems to be true for setting btw.
See rna_AttributeGroup_active_get / rna_AttributeGroup_active_set, this does not have a relation the AttributeGroup, this just handles all attributes.

Note: even in 3.3, the logic is wrong. `color_attributes.active` will always return the active attribute (no matter if color or not). It just happens to be that in 3.3, there is no real attribute there yet on the default cube Same seems to be true for setting btw. See `rna_AttributeGroup_active_get` / `rna_AttributeGroup_active_set`, this does not have a relation the AttributeGroup, this just handles **all** attributes.
Member

Not sure if the original plan with attributes was really to have multiple AttributeGroup , @brecht @HooglyBoogly ?

eae36be372 made up a new AttributeGroup, breaking some of the API...

Not sure if the original plan with attributes was really to have multiple `AttributeGroup` , @brecht @HooglyBoogly ? eae36be372a6 made up a new `AttributeGroup`, breaking some of the API...
Philipp Oeser changed title from Regression: Python: wrong mesh.color_attributes.active to AttributeGroup API: "active" is meaningless (always refers to all attributes, not the specific AttributeGroup) -- e.g. mesh.color_attributes.active 2023-04-21 09:17:54 +02:00

Hm. this make it a bit above my pay grade ;-) .

I could still look into it if others don't have time, but I'd be slow.

Hm. this make it a bit above my pay grade ;-) . I *could* still look into it if others don't have time, but I'd be slow.
Member

Thinking about it further, making some of the API specific to the actual AttributeGroup, we could get rid of lots of handling of color vs. other attributes:

  • active_color vs active
  • active_color_index vs active_index
  • render_color_index, default_color_name, active_color_name, ... could all just be in the colors AttributeGroup
  • no need for active_color string handling on mesh, really, could just be retrieved from active (on the right AttributeGroup)
Thinking about it further, making some of the API specific to the actual `AttributeGroup`, we could get rid of lots of handling of color vs. other attributes: - `active_color` vs `active` - `active_color_index` vs `active_index` - `render_color_index`, `default_color_name`, `active_color_name`, ... could all just be in the colors `AttributeGroup` - no need for active_color string handling on mesh, really, could just be retrieved from active (on the right `AttributeGroup`)

but I see there's also a rna_AttributeGroup_active_color_get shouldn't it just use that one instead? That does limit the search to color attributes.

but I see there's also a rna_AttributeGroup_active_*color*_get shouldn't it just use that one instead? That *does* limit the search to color attributes.

C.object.data.color_attributes.active_color does call the correct function and return the correct result. But that's rather counterintuitive

I think @lichtwerk 's suggestion above is the way to go.

C.object.data.color_attributes.active_color *does* call the correct function and return the correct result. But that's rather counterintuitive I think @lichtwerk 's suggestion above is the way to go.

As a workaround, using C.object.data.color_attributes.active_color gives the correct result.

As a workaround, using `C.object.data.color_attributes.active_color` gives the correct result.

Just as PSA: I don't have time to look into this at the moment. In case someone hoped I would ;-)

Just as PSA: I don't have time to look into this at the moment. In case someone hoped I would ;-)

I think this is not a bug per-se . It's more a case of bad documentation and a slightly clumsy api.

I think we could remove the hi prio

I think this is not a bug per-se . It's more a case of bad documentation and a slightly clumsy api. I think we could remove the hi prio
Pratik Borhade added
Severity
Normal
and removed
Severity
High
labels 2023-06-17 12:57:22 +02:00
Bart van der Braak added
Type
Bug
and removed
Type
Report
labels 2024-08-14 13:13:12 +02:00
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
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#107194
No description provided.