New vertex groups cannot be operated upon ... until? #60517

Closed
opened 2019-01-15 03:17:51 +01:00 by sok0 · 18 comments

System Information
Operating system: Windows 10
Graphics card: GTX 970

Blender Version
example: 2.79b release

There is a problem with the way the Blender handles newly created vertex groups that causes numerous problems.

  1. Tools > Weight Tools - These tools do not work on newly created vertex groups.
  2. The Fix Deforms tool immediately crashes blender.
  3. Bmesh cannot access vertex groups layer and returns: AttributeError: BMElem[key]: invalid key, must be a BMLayerItem

To recreate:

  1. Open new Blend
  2. Create Cube
  3. Add Vertex Group
  4. Enter Weight Paint Mode
  5. Press V to enter Vertex Mask mode
  6. If required, press A to select all vertices
  7. Press Tools > Weight Tools > Invert
  8. Nothing happens
  9. Press Fix Deforms
  10. Blender crashes

Using the weight paint brush in an empty space, or manually assigning a vertex to the vertex group in the properties window will allow the weight tools to work as expected. However this is not an acceptable workaround when using Bmesh to manager vertex groups.

**System Information** Operating system: Windows 10 Graphics card: GTX 970 **Blender Version** example: 2.79b release There is a problem with the way the Blender handles newly created vertex groups that causes numerous problems. 1. Tools > Weight Tools - These tools do not work on newly created vertex groups. 2. The Fix Deforms tool immediately crashes blender. 3. Bmesh cannot access vertex groups layer and returns: AttributeError: BMElem[key]: invalid key, must be a BMLayerItem To recreate: 1. Open new Blend 2. Create Cube 3. Add Vertex Group 4. Enter Weight Paint Mode 5. Press V to enter Vertex Mask mode 6. If required, press A to select all vertices 7. Press Tools > Weight Tools > Invert 8. Nothing happens 9. Press Fix Deforms 10. Blender crashes Using the weight paint brush in an empty space, or manually assigning a vertex to the vertex group in the properties window will allow the weight tools to work as expected. However this is not an acceptable workaround when using Bmesh to manager vertex groups.
Author

Added subscriber: @sok0

Added subscriber: @sok0
Author
[untitled.blend](https://archive.blender.org/developer/F6290591/untitled.blend)
Author

in the attached file the script fails on the newly created vertex group "Group":

Traceback (most recent call last):

File "C:\Users\Greg\Desktop\untitled2.blend\Text", line 18, in <module>

AttributeError: BMElem[key]: invalid key, must be a BMLayerItem

If the vertex group is initialized such as by assigning vertices to the group manually, prior to running the script, then the script will run without errors.

untitled2.blend

in the attached file the script fails on the newly created vertex group "Group": Traceback (most recent call last): ``` File "C:\Users\Greg\Desktop\untitled2.blend\Text", line 18, in <module> ``` AttributeError: BMElem[key]: invalid key, must be a BMLayerItem If the vertex group is initialized such as by assigning vertices to the group manually, prior to running the script, then the script will run without errors. [untitled2.blend](https://archive.blender.org/developer/F6290644/untitled2.blend)
Author

For a new vertex group:
.verts.layers.deform.items() returns []
.verts.layers.deform.active returns None

For a vertex group that has had a manual weight paint brush stroke or vertex assignment in the properties panel, respectively:
[('', <BMLayerItem object at 0x000002D11EB10300>)]
<BMLayerItem object at 0x000002D11EB10300>

For a new vertex group: <Bmesh objects>.verts.layers.deform.items() returns [] <Bmesh object>.verts.layers.deform.active returns None For a vertex group that has had a manual weight paint brush stroke or vertex assignment in the properties panel, respectively: [('', <BMLayerItem object at 0x000002D11EB10300>)] <BMLayerItem object at 0x000002D11EB10300>
Author

Sorry for blowing up the thread, but found a solution: The following script will create the needed BMLayerItem object so that Weight Tools may be used on a newly created Vertex Group

import bpy 
import bmesh

obj = bpy.data.objects['Cube']
group_index = obj.vertex_groups.active_index #Initialize active group

mesh = bpy.data.meshes['Cube']

bm = bmesh.new()
bm.from_mesh(mesh)

bm.verts.layers.deform.verify() #This must be called prior to Weight Tools

bm.to_mesh(mesh)
bm.free()

Initilize VG for Tools.blend

Sorry for blowing up the thread, but found a solution: The following script will create the needed BMLayerItem object so that Weight Tools may be used on a newly created Vertex Group ``` import bpy import bmesh obj = bpy.data.objects['Cube'] group_index = obj.vertex_groups.active_index #Initialize active group mesh = bpy.data.meshes['Cube'] bm = bmesh.new() bm.from_mesh(mesh) bm.verts.layers.deform.verify() #This must be called prior to Weight Tools bm.to_mesh(mesh) bm.free() ``` [Initilize VG for Tools.blend](https://archive.blender.org/developer/F6291654/Initilize_VG_for_Tools.blend)
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Based on your new discoveries, could you please rephrase what the bug is?
Also remember that there should only be one bug per report. If you experience more bugs, create a separate report for each.

Based on your new discoveries, could you please rephrase what the bug is? Also remember that there should only be one bug per report. If you experience more bugs, create a separate report for each.
Author

The bug is that Weight Tools do not work as expected, possibly because .verts.layers.deform.verify() is needed to fix it

The bug is that Weight Tools do not work as expected, possibly because <bmesh>.verts.layers.deform.verify() is needed to fix it

Added subscriber: @ZedDB

Added subscriber: @ZedDB
Sergey Sharybin was assigned by Sebastian Parborg 2019-03-13 11:32:22 +01:00

I'm getting this with 2.8 if I follow the instructions in the description:
BLI_assert failed: /home/zed/programmering/blender_master/blender/source/blender/blenkernel/intern/DerivedMesh.c:2294, mesh_get_eval_deform(), at 'ob->id.tag & LIB_TAG_COPIED_ON_WRITE'

And the BT if I disregard the asserts:

Thread 1 "blender" received signal SIGSEGV, Segmentation fault.
0x00005555577614bf in moveCloserToDistanceFromPlane (depsgraph=0x7fffe3351008, scene=0x7fffe4f6a008, ob=0x7fffcf12a808, me=0x7fffcef47908, index=0,
    norm=0x7fffffffd4a4, coord=0x7fffffffd498, d=-0.577350318, distToBe=0, strength=1, cp=1)
    at /home/zed/programmering/blender_master/blender/source/blender/editors/object/object_vgroup.c:1272
1272		int totweight = dvert->totweight;
(gdb) bt
#0  0x00005555577614bf in moveCloserToDistanceFromPlane (depsgraph=0x7fffe3351008, scene=0x7fffe4f6a008, ob=0x7fffcf12a808, me=0x7fffcef47908, index=0,
    norm=0x7fffffffd4a4, coord=0x7fffffffd498, d=-0.577350318, distToBe=0, strength=1, cp=1)
    at /home/zed/programmering/blender_master/blender/source/blender/editors/object/object_vgroup.c:1272
#1  0x000055555776246a in vgroup_fix (C=0x7fffea058188, scene=0x7fffe4f6a008, ob=0x7fffcf12a808, distToBe=0, strength=1, cp=1)
    at /home/zed/programmering/blender_master/blender/source/blender/editors/object/object_vgroup.c:1479
#2  0x000055555776a288 in vertex_group_fix_exec (C=0x7fffea058188, op=0x7fffd8479988)
    at /home/zed/programmering/blender_master/blender/source/blender/editors/object/object_vgroup.c:3017
#3  0x0000555557224fde in wm_operator_invoke (C=0x7fffea058188, ot=0x7fffe4d66e88, event=0x7fffd8476a08, properties=0x7fffffffd6f0, reports=0x0,
    poll_only=false, use_last_properties=true) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:1353
#4  0x000055555722567b in wm_operator_call_internal (C=0x7fffea058188, ot=0x7fffe4d66e88, properties=0x7fffffffd6f0, reports=0x0, context=1, poll_only=false,
    event=0x7fffd8476a08) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:1550
#5  0x000055555722589e in WM_operator_name_call_ptr (C=0x7fffea058188, ot=0x7fffe4d66e88, context=1, properties=0x7fffffffd6f0)
    at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:1598
#6  0x0000555557569006 in ui_apply_but_funcs_after (C=0x7fffea058188)
    at /home/zed/programmering/blender_master/blender/source/blender/editors/interface/interface_handlers.c:770
#7  0x0000555557581e56 in ui_handler_region_menu (C=0x7fffea058188, event=0x7fffcc355b88, UNUSED_userdata=0x7fffd850e308)
    at /home/zed/programmering/blender_master/blender/source/blender/editors/interface/interface_handlers.c:9903
#8  0x0000555557222c66 in wm_handler_ui_call (C=0x7fffea058188, handler=0x7fffcf14c268, event=0x7fffcc355b88, always_pass=0)
    at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:585
#9  0x0000555557227da0 in wm_handlers_do_intern (C=0x7fffea058188, event=0x7fffcc355b88, handlers=0x7fffe4e52198)
    at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:2491
#10 0x0000555557228777 in wm_handlers_do (C=0x7fffea058188, event=0x7fffcc355b88, handlers=0x7fffe4e52198)
    at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:2720
#11 0x00005555572299ab in wm_event_do_handlers (C=0x7fffea058188)
    at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:3071
- 12 0x000055555721e1cf in WM_main (C=0x7fffea058188) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm.c:418
- 13 0x0000555557218904 in main (argc=1, argv=0x7fffffffdd28) at /home/zed/programmering/blender_master/blender/source/creator/creator.c:505
I'm getting this with 2.8 if I follow the instructions in the description: `BLI_assert failed: /home/zed/programmering/blender_master/blender/source/blender/blenkernel/intern/DerivedMesh.c:2294, mesh_get_eval_deform(), at 'ob->id.tag & LIB_TAG_COPIED_ON_WRITE'` And the BT if I disregard the asserts: ``` Thread 1 "blender" received signal SIGSEGV, Segmentation fault. 0x00005555577614bf in moveCloserToDistanceFromPlane (depsgraph=0x7fffe3351008, scene=0x7fffe4f6a008, ob=0x7fffcf12a808, me=0x7fffcef47908, index=0, norm=0x7fffffffd4a4, coord=0x7fffffffd498, d=-0.577350318, distToBe=0, strength=1, cp=1) at /home/zed/programmering/blender_master/blender/source/blender/editors/object/object_vgroup.c:1272 1272 int totweight = dvert->totweight; (gdb) bt #0 0x00005555577614bf in moveCloserToDistanceFromPlane (depsgraph=0x7fffe3351008, scene=0x7fffe4f6a008, ob=0x7fffcf12a808, me=0x7fffcef47908, index=0, norm=0x7fffffffd4a4, coord=0x7fffffffd498, d=-0.577350318, distToBe=0, strength=1, cp=1) at /home/zed/programmering/blender_master/blender/source/blender/editors/object/object_vgroup.c:1272 #1 0x000055555776246a in vgroup_fix (C=0x7fffea058188, scene=0x7fffe4f6a008, ob=0x7fffcf12a808, distToBe=0, strength=1, cp=1) at /home/zed/programmering/blender_master/blender/source/blender/editors/object/object_vgroup.c:1479 #2 0x000055555776a288 in vertex_group_fix_exec (C=0x7fffea058188, op=0x7fffd8479988) at /home/zed/programmering/blender_master/blender/source/blender/editors/object/object_vgroup.c:3017 #3 0x0000555557224fde in wm_operator_invoke (C=0x7fffea058188, ot=0x7fffe4d66e88, event=0x7fffd8476a08, properties=0x7fffffffd6f0, reports=0x0, poll_only=false, use_last_properties=true) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:1353 #4 0x000055555722567b in wm_operator_call_internal (C=0x7fffea058188, ot=0x7fffe4d66e88, properties=0x7fffffffd6f0, reports=0x0, context=1, poll_only=false, event=0x7fffd8476a08) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:1550 #5 0x000055555722589e in WM_operator_name_call_ptr (C=0x7fffea058188, ot=0x7fffe4d66e88, context=1, properties=0x7fffffffd6f0) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:1598 #6 0x0000555557569006 in ui_apply_but_funcs_after (C=0x7fffea058188) at /home/zed/programmering/blender_master/blender/source/blender/editors/interface/interface_handlers.c:770 #7 0x0000555557581e56 in ui_handler_region_menu (C=0x7fffea058188, event=0x7fffcc355b88, UNUSED_userdata=0x7fffd850e308) at /home/zed/programmering/blender_master/blender/source/blender/editors/interface/interface_handlers.c:9903 #8 0x0000555557222c66 in wm_handler_ui_call (C=0x7fffea058188, handler=0x7fffcf14c268, event=0x7fffcc355b88, always_pass=0) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:585 #9 0x0000555557227da0 in wm_handlers_do_intern (C=0x7fffea058188, event=0x7fffcc355b88, handlers=0x7fffe4e52198) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:2491 #10 0x0000555557228777 in wm_handlers_do (C=0x7fffea058188, event=0x7fffcc355b88, handlers=0x7fffe4e52198) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:2720 #11 0x00005555572299ab in wm_event_do_handlers (C=0x7fffea058188) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_event_system.c:3071 - 12 0x000055555721e1cf in WM_main (C=0x7fffea058188) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm.c:418 - 13 0x0000555557218904 in main (argc=1, argv=0x7fffffffdd28) at /home/zed/programmering/blender_master/blender/source/creator/creator.c:505 ```
Member

@sok0, can you explain me what the "Fix Deforms" operation is supposed to do?
Could not find any useful information. The code for it seems to be bad in many regards.
Also I found this: #32406
Does not look like this has ever been corrected.

@sok0, can you explain me what the "Fix Deforms" operation is supposed to do? Could not find any useful information. The code for it seems to be bad in many regards. Also I found this: #32406 Does not look like this has ever been corrected.
Author

In #60517#652805, @JacquesLucke wrote:
@sok0, can you explain me what the "Fix Deforms" operation is supposed to do?

I've read the documentation and I assumed it was some kind of algorithm that adjusts ratios of bone weights for deforms that cause excessive clipping. In practice i've never seen it do anything.

> In #60517#652805, @JacquesLucke wrote: > @sok0, can you explain me what the "Fix Deforms" operation is supposed to do? I've read the documentation and I assumed it was some kind of algorithm that adjusts ratios of bone weights for deforms that cause excessive clipping. In practice i've never seen it do anything.
Sergey Sharybin removed their assignment 2019-06-13 15:25:20 +02:00

Added subscriber: @Sergey

Added subscriber: @Sergey

@ZedDB, i've made current master (9d269a97be) to work the same as 2.79 with "Fix Deform". There is no much more i can do here.
The original report is about 2.79, and i can only make .280 work same as 2.79 in areas i am absolutely not familiar with.

@ZedDB, i've made current master (9d269a97be) to work the same as 2.79 with "Fix Deform". There is no much more i can do here. The original report is about 2.79, and i can only make .280 work same as 2.79 in areas i am absolutely not familiar with.

Added subscriber: @iss

Added subscriber: @iss

Still crashes in 2.83 in Fix Deforms operator code

MDeformVert *dvert was null

Still crashes in 2.83 in Fix Deforms operator code `MDeformVert *dvert` was null

This issue was referenced by 101c3d4ce4

This issue was referenced by 101c3d4ce4554a4d00ff89830c6b500f3e986365

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Campbell Barton self-assigned this 2020-11-04 01:25:30 +01: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
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#60517
No description provided.