Scripting: creating a corner-domain color attribute doesn't make it active #103564

Closed
opened 2022-12-31 05:54:28 +01:00 by Scurest · 16 comments
Contributor

System Information
Operating system: Linux

Blender Version
Broken: blender-3.5.0-alpha+master.3340cc810203-linux.x86_64-release

Short description of error
Creating a color attribute with "Face Corner" domain on a mesh with no color attributes does not always make the new attribute active.

Exact steps for others to reproduce the error
Create a cube and then run this script.

import bpy
mesh = bpy.context.object.data
for domain in ['POINT', 'CORNER']:
    for type in ['FLOAT_COLOR', 'BYTE_COLOR']:
        attr = mesh.color_attributes.new('Color', type, domain)
        print(domain, type, mesh.color_attributes.active)
        mesh.color_attributes.remove(attr)

Observe that the active color attribute is None for both CORNER domain cases.

Somewhat bizarrely, this does work if you use mesh = bpy.data.meshes.new('TestMesh') instead of your cube.

**System Information** Operating system: Linux **Blender Version** Broken: blender-3.5.0-alpha+master.3340cc810203-linux.x86_64-release **Short description of error** Creating a color attribute with "Face Corner" domain on a mesh with no color attributes does not always make the new attribute active. **Exact steps for others to reproduce the error** Create a cube and then run this script. ``` import bpy mesh = bpy.context.object.data for domain in ['POINT', 'CORNER']: for type in ['FLOAT_COLOR', 'BYTE_COLOR']: attr = mesh.color_attributes.new('Color', type, domain) print(domain, type, mesh.color_attributes.active) mesh.color_attributes.remove(attr) ``` Observe that the active color attribute is `None` for both CORNER domain cases. Somewhat bizarrely, this *does* work if you use `mesh = bpy.data.meshes.new('TestMesh')` instead of your cube.
Author
Contributor

Added subscriber: @scurest

Added subscriber: @scurest

Added subscriber: @mod_moder

Added subscriber: @mod_moder

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

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

I've found strange behaviors in how the active attribute works exactly.

it moves An active color attribute is only visible if there is an active attribute
2022-12-31 11-30-56.mp4 2022-12-31 11-39-13.mp4

Is it normal for an attribute to not be active?
Yes, as described in the report, the code will print only the first 2 attributes as active of the 4 created

POINT FLOAT_COLOR <bpy_struct, FloatColorAttribute("Color") at 0x00000164947846F8>
POINT BYTE_COLOR <bpy_struct, ByteColorAttribute("Color") at 0x00000164947846F8>
CORNER FLOAT_COLOR None
CORNER BYTE_COLOR None
I've found strange behaviors in how the active attribute works exactly. | it moves | An active color attribute is only visible if there is an active attribute | | -- | -- | | [2022-12-31 11-30-56.mp4](https://archive.blender.org/developer/F14101787/2022-12-31_11-30-56.mp4) | [2022-12-31 11-39-13.mp4](https://archive.blender.org/developer/F14101788/2022-12-31_11-39-13.mp4) | Is it normal for an attribute to not be active? Yes, as described in the report, the code will print only the first 2 attributes as active of the 4 created ```lang=bat POINT FLOAT_COLOR <bpy_struct, FloatColorAttribute("Color") at 0x00000164947846F8> POINT BYTE_COLOR <bpy_struct, ByteColorAttribute("Color") at 0x00000164947846F8> CORNER FLOAT_COLOR None CORNER BYTE_COLOR None ```
Member

Added subscriber: @JulienDuroure

Added subscriber: @JulienDuroure
Author
Contributor

I don't know if this is related, but creating the color attribute also doesn't make it active for rendering (the little camera next to the name). This is different that how UV maps behave. This also means it doesn't work with eg. Color Attribute nodes with a blank name. I know this used to work in previous versions.

I don't know if this is related, but creating the color attribute also doesn't make it active for rendering (the little camera next to the name). This is different that how UV maps behave. This also means it doesn't work with eg. Color Attribute nodes with a blank name. I know this used to work in previous versions.
Member

Added subscriber: @HooglyBoogly

Added subscriber: @HooglyBoogly
Member

creating the color attribute also doesn't make it active for rendering (the little camera next to the name)

This definitely sounds like a bug. But I think the new behavior for making a color attribute active is better. Just creating a new color attribute with the Python API probably shouldn't change the active status, in case it was set explicitly by the user.

>creating the color attribute also doesn't make it active for rendering (the little camera next to the name) This definitely sounds like a bug. But I think the new behavior for making a color attribute active is better. Just creating a new color attribute with the Python API probably shouldn't change the active status, in case it was set explicitly by the user.
Author
Contributor

The report is about creating the first color attribute though. I expect if there's only one, it's active. I'm not sure what the behavior is when there are already other color attributes.

edit: For UV maps, creating the first UV map makes it active. Creating subsequent ones does not change the active map. I think this is how color attributes should work (and I think they did use to work that way).

The report is about creating the first color attribute though. I expect if there's only one, it's active. I'm not sure what the behavior is when there are already other color attributes. edit: For UV maps, creating the first UV map makes it active. Creating subsequent ones does not change the active map. I think this is how color attributes should work (and I think they did use to work that way).
Member

Ah, I see. That sounds more reasonable I suppose. Thanks.

Ah, I see. That sounds more reasonable I suppose. Thanks.
Member

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

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

This issue was referenced by 101d04f41f

This issue was referenced by 101d04f41ffbb72bf20e7c2b15f1bb868328cd03
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Philipp Oeser self-assigned this 2023-01-03 11:42:38 +01:00
Author
Contributor

Sorry, I just tried blender-3.5.0-alpha+master.1beaec46b8e3 and this still seems to work only sometimes.

  1. Adding a vertex color through the old API C.object.data.vertex_colors.new(name="Color") to a newly created Cube does not make the color attribute active/default. Note that if you select the color attribute in the UI, delete it, and then run the same line again though, the second time it does make it active/default. So there's something weird going on.

  2. Importing a .dae/.obj file with vertex colors results in a color attribute that's active, but not default (the little camera).

Sorry, I just tried blender-3.5.0-alpha+master.1beaec46b8e3 and this still seems to work only sometimes. 1. Adding a vertex color through the old API `C.object.data.vertex_colors.new(name="Color")` to a newly created Cube does not make the color attribute active/default. Note that if you select the color attribute in the UI, delete it, and then run the same line again though, the second time it *does* make it active/default. So there's something weird going on. 2. Importing a .dae/.obj file with vertex colors results in a color attribute that's active, but not default (the little camera).
Author
Contributor
@lichtwerk
Member

@scurest : could you create a new report for both of these? (since these are a bit different than color_attributes.new.

Feel free to subscribe me there (or even assign to me)

@scurest : could you create a new report for both of these? (since these are a bit different than `color_attributes.new`. Feel free to subscribe me there (or even assign to me)
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
7 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#103564
No description provided.