Mesh.attributes.new() returns None if named the same as a Vertex Group #103410

Closed
opened 2022-12-22 16:50:17 +01:00 by Zach Eastin · 20 comments

System Information
Operating system: Windows-10-10.0.22621-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 517.40

Blender Version
Broken: version: 3.4.0, branch: blender-v3.4-release, commit date: 2022-12-06 18:46, hash: a95bf1ac01
Worked: Never? Doesn't work in 3.3 at least

Since 101d04f41f, this now crashes

Short description of error
When creating a new attribute if it is named the same as an existing vertex group None is returned and no information is given as to why it was returned None

Exact steps for others to reproduce the error

  1. Open Blender
  2. Add Vertex Group to the Default Cube (leave it named 'Group')
  3. Add a new attribute (or color_attribute) to the object in the python console C.object.data.attributes.new('Group', 'FLOAT', 'POINT')
  4. This returns None without any information given that it is because it's named the same as a Vertex Group but that you can't access Vertex Groups through attributes (or something)

I understand Vertex Groups are in this quasi-middle area right now between object and mesh and this is probably why this happens but maybe an error should be thrown since nothing is returned even though the command was correct.

**System Information** Operating system: Windows-10-10.0.22621-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 2080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 517.40 **Blender Version** Broken: version: 3.4.0, branch: blender-v3.4-release, commit date: 2022-12-06 18:46, hash: `a95bf1ac01` Worked: Never? Doesn't work in 3.3 at least Since 101d04f41ffbb72bf20e7c2b15f1bb868328cd03, this now crashes **Short description of error** When creating a new attribute if it is named the same as an existing vertex group `None` is returned and no information is given as to why it was returned None **Exact steps for others to reproduce the error** 1. Open Blender 2. Add Vertex Group to the Default Cube (leave it named 'Group') 3. Add a new attribute (or color_attribute) to the object in the python console `C.object.data.attributes.new('Group', 'FLOAT', 'POINT')` 4. This returns `None` without any information given that it is because it's named the same as a Vertex Group but that you can't access Vertex Groups through attributes (or something) I understand Vertex Groups are in this quasi-middle area right now between object and mesh and this is probably why this happens but maybe an error should be thrown since nothing is returned even though the command was correct.
Author

Added subscriber: @Zeastin

Added subscriber: @Zeastin
Contributor

Added subscriber: @scurest

Added subscriber: @scurest

Added subscribers: @HooglyBoogly, @mod_moder

Added subscribers: @HooglyBoogly, @mod_moder

This is because the vertex weights will be completely replaced by attributes.
And in that case, it's a feature request.
@HooglyBoogly

This is because the vertex weights will be completely replaced by attributes. And in that case, it's a feature request. @HooglyBoogly
Author

All I'm asking for in this report is just some feedback for the programmer when using the attributes.new() command until vertex groups can be fully moved over to attributes. This happens in the current LTS (3.3) as well which won't get any updates or new features for another 6 months when the next LTS is released.

All I'm asking for in this report is just some feedback for the programmer when using the attributes.new() command until vertex groups can be fully moved over to attributes. This happens in the current LTS (3.3) as well which won't get any updates or new features for another 6 months when the next LTS is released.

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
Member

I think it's reasonable to expect an error message here. Unfortunately that's more difficult than it should be internally, since the attribute API doesn't give error messages now. But it's theoretically possible.

I think it's reasonable to expect an error message here. Unfortunately that's more difficult than it should be internally, since the attribute API doesn't give error messages now. But it's theoretically possible.
Contributor

Could it bump up to the next name, eg. Group.001, as if Group existed?

Could it bump up to the next name, eg. `Group.001`, as if `Group` existed?
Member

Good idea, that might be a more consistent solution.

For any developers interested in implementing this, that would involve also looking through vertex group names (Mesh.vertex_group_names) in BKE_id_attribute_calc_unique_name.

Good idea, that might be a more consistent solution. For any developers interested in implementing this, that would involve also looking through vertex group names (`Mesh.vertex_group_names`) in `BKE_id_attribute_calc_unique_name`.
Member

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'

Should the tribute capture attribute node take this into account too?

Should the tribute capture attribute node take this into account too?

I've added a check to create attribute names.
So everything works.
But it seems that it is needed not only for creating attributes...
Here I first created the attributes, and then the weights of the vertices:
image.png

I've added a check to create attribute names. So everything works. But it seems that it is needed not only for creating attributes... Here I first created the attributes, and then the weights of the vertices: ![image.png](https://archive.blender.org/developer/F14085994/image.png)

Added subscriber: @Baardaap

Added subscriber: @Baardaap

The vertex group code doesn't know about attributes at all. So I think it's pretty hard to check for already existing attribute names over there. At least the warning is displayed when the attribute system detects the collision, though it's a pity it's only displayed on the (by default collapsed) attributes panel and not also on the Vertex groups panel.

Vertex groups probably won't be attributes for quite a long time, because vertex groups can be stored sparsely (which is absolutely needed for armature weights) while attributes can't. So it might be worth it to display this warning also in the Vertex Group panel?

Or maybe we should just factor in a check for existing attributes in the vertex group system after all. I think it was not done because 'eventually vertex groups go away'...

The vertex group code doesn't know about attributes at all. So I think it's pretty hard to check for already existing attribute names over there. At least the warning is displayed when the attribute system detects the collision, though it's a pity it's only displayed on the (by default collapsed) attributes panel and not also on the Vertex groups panel. Vertex groups probably won't be attributes for quite a long time, because vertex groups can be stored sparsely (which is absolutely needed for armature weights) while attributes can't. So it might be worth it to display this warning also in the Vertex Group panel? Or maybe we should just factor in a check for existing attributes in the vertex group system after all. I think it was not done because 'eventually vertex groups go away'...

Added subscriber: @Suyash-Sapkal

Added subscriber: @Suyash-Sapkal

Added subscriber: @Fiona-Gallagher

Added subscriber: @Fiona-Gallagher
Philipp Oeser removed the
Interest
Animation & Rigging
label 2023-02-09 14:34:42 +01:00
Member

Crash in recent versions due to failure in finding customdata-layer.

Crash in recent versions due to failure in finding customdata-layer.
Pratik Borhade added
Module
Modeling
and removed
Module
Animation & Rigging
labels 2023-07-05 14:05:06 +02:00
Member

Since 101d04f41f, this now crashes

Will check why that is and temporarily raise priority until at least the crash is gone again

Since 101d04f41ffbb72bf20e7c2b15f1bb868328cd03, this now crashes Will check why that is and temporarily raise priority until at least the crash is gone again
Philipp Oeser added
Priority
High
and removed
Meta
Good First Issue
Priority
Normal
labels 2023-07-10 09:52:43 +02:00
Member

Will (at least temporarily) put on my desk

Will (at least temporarily) put on my desk
Philipp Oeser self-assigned this 2023-07-10 10:24:13 +02:00
Member

The vertex group code doesn't know about attributes at all. So I think it's pretty hard to check for already existing attribute names over there.

@Baardaap : pushed some code around so we can run both callbacks on both places,, if you are interested, put up a PR, see #109910

> The vertex group code doesn't know about attributes at all. So I think it's pretty hard to check for already existing attribute names over there. @Baardaap : pushed some code around so we can run both callbacks on both places,, if you are interested, put up a PR, see #109910
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-08-08 10:12:02 +02:00
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
9 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#103410
No description provided.