Get face map values in edit mode #85398

Closed
opened 2021-02-05 11:43:34 +01:00 by Sergey · 15 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: Intel(R) HD Graphics 630 Intel 4.5.0 - Build 25.20.100.6471

Blender Version
Broken: version: 2.91.0, branch: master, commit date: 2020-11-25 08:34, hash: 0f45cab862

Short description of error
I'm trying utilize face maps. The question is that I can't get actual face map status from polygons when a mesh is in edit mode. As far as I know there is no such problem with other mesh attributes. At least active material can be definitely received from mesh in edit mode. Is it bug or limitation?
2021-02-05 14-33-00.mp4

Exact steps for others to reproduce the error

test.blend

  1. Dowload file
  2. Run script
  3. Get into edit mode
  4. Change face map set
  5. Run script again
  6. Compare prints in cosole - there should not be difference
**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: Intel(R) HD Graphics 630 Intel 4.5.0 - Build 25.20.100.6471 **Blender Version** Broken: version: 2.91.0, branch: master, commit date: 2020-11-25 08:34, hash: `0f45cab862` **Short description of error** I'm trying utilize face maps. The question is that I can't get actual `face map` status from polygons when a mesh is in edit mode. As far as I know there is no such problem with other mesh attributes. At least `active material` can be definitely received from mesh in edit mode. Is it bug or limitation? [2021-02-05 14-33-00.mp4](https://archive.blender.org/developer/F9651432/2021-02-05_14-33-00.mp4) **Exact steps for others to reproduce the error** [test.blend](https://archive.blender.org/developer/F9651480/test.blend) 1. Dowload file 2. Run script 3. Get into edit mode 4. Change face map set 5. Run script again 6. Compare prints in cosole - there should not be difference
Author

Added subscriber: @randum

Added subscriber: @randum
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

You have to read this from the evaluated object like so:

import bpy
import bmesh

depsgraph = bpy.context.evaluated_depsgraph_get()
object_eval = bpy.context.active_object.evaluated_get(depsgraph)
me_eval = object_eval.to_mesh()

bm = bmesh.new()
bm.from_mesh(me_eval)
object_eval.to_mesh_clear()

l = bm.faces.layers.face_map.active
print([f[l] for f in bm.faces])
bm.free()

test_corrected.blend

You have to read this from the evaluated object like so: ``` import bpy import bmesh depsgraph = bpy.context.evaluated_depsgraph_get() object_eval = bpy.context.active_object.evaluated_get(depsgraph) me_eval = object_eval.to_mesh() bm = bmesh.new() bm.from_mesh(me_eval) object_eval.to_mesh_clear() l = bm.faces.layers.face_map.active print([f[l] for f in bm.faces]) bm.free() ``` [test_corrected.blend](https://archive.blender.org/developer/F9654181/test_corrected.blend)
Member

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Philipp Oeser self-assigned this 2021-02-05 14:03:07 +01:00
Member

Afaict, this is not a bug, see here also https://docs.blender.org/api/master/bpy.types.Depsgraph.html

Will close (but feel free to comment again if issues persist -- or if you really think this is an exception to how blenders python API works in other areas [what I havent checked is what you mentioned with active material since this is not in face.layers?] -- we can always repoen in this case)

Afaict, this is not a bug, see here also https://docs.blender.org/api/master/bpy.types.Depsgraph.html Will close (but feel free to comment again if issues persist -- or if you really think this is an exception to how blenders python API works in other areas [what I havent checked is what you mentioned with `active material` since this is not in face.layers?] -- we can always repoen in this case)
Author

I was basing on documentation of getting access to bmesh layers (https://docs.blender.org/api/current/bmesh.html#customdata-access) in my attempt.

In the examples there is nothing about necessity of evaluating depsgraph. I've tried getting access to weights of a vertices group in edit mode and was succeeded without calling depsgraph.

Also it described in the documentation that depsfraph should be used only to get data with applied animation, drivers, modifiers and constrains and there is nothing about face maps or other mesh attributes.

It seems to me that either documentation is not accurate about using face maps or face maps really behave their selves inadequate compared to other mesh attributes.

I was basing on documentation of getting access to `bmesh` layers (https://docs.blender.org/api/current/bmesh.html#customdata-access) in my attempt. In the examples there is nothing about necessity of evaluating `depsgraph`. I've tried getting access to weights of a vertices group in edit mode and was succeeded without calling depsgraph. Also it described in the documentation that `depsfraph` should be used only to get data with applied animation, drivers, modifiers and constrains and there is nothing about face maps or other mesh attributes. It seems to me that either documentation is not accurate about using face maps or face maps really behave their selves inadequate compared to other mesh attributes.
Member

Changed status from 'Resolved' to: 'Needs Triage'

Changed status from 'Resolved' to: 'Needs Triage'
Member

Needs another look

Needs another look

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Archived'

Changed status from 'Needs Triage' to: 'Archived'

While in edit mode, the object's mesh (object.data) is not updated.
Only BMesh, Mesh Cage and Mesh Final are updated.
You have to copy the BMesh from the Mesh (bmesh.from_edit_mesh(me))

This is known behavior and not considered a bug.
It's preferable that way for performance.

While in edit mode, the object's mesh (`object.data`) is not updated. Only BMesh, Mesh Cage and Mesh Final are updated. You have to copy the `BMesh` from the `Mesh` (`bmesh.from_edit_mesh(me)`) This is known behavior and not considered a bug. It's preferable that way for performance.
Author

I've tried to use from_edit_mesh method and it works but only once. The second attempt always lead to a crash. Am I doing something wrong? Should I open another task with crash report?

test.blend

2021-07-28 08-13-58.mp4

I've tried to use `from_edit_mesh` method and it works but only once. The second attempt always lead to a crash. Am I doing something wrong? Should I open another task with crash report? [test.blend](https://archive.blender.org/developer/F10242265/test.blend) [2021-07-28 08-13-58.mp4](https://archive.blender.org/developer/F10242263/2021-07-28_08-13-58.mp4)

Added subscriber: @Debuk

Added subscriber: @Debuk

Make a copy of it or dont free it

bm = bmesh.from_edit_mesh(me).copy()

https://docs.blender.org/api/current/bmesh.types.html#bmesh.types.BMesh.free

Make a copy of it or dont free it ``` bm = bmesh.from_edit_mesh(me).copy() ``` https://docs.blender.org/api/current/bmesh.types.html#bmesh.types.BMesh.free
Author

@Debuk Thanks. Now it works as expected.

@Debuk Thanks. Now it works as expected.
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#85398
No description provided.