Crash when passing geom and context to bmesh.ops.delete when all is selected #50920
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#50920
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This started from a question at [BSE ]]. The example file can be found [ https:*drive.google.com/open?id=0B9DFPZBPKp6AdERZTmJWeGE0RFE | here (google drive 500k)
The file contains a single mesh object made of two cubes and a plane and has the following script -
if f.calc_center_bounds().y < 0:
delete_first.append(f)
vn, en, fn = len(bm.verts), len(bm.edges), len(bm.faces)
ret = bmesh.ops.bisect_plane(bm, geom=geom, plane_co=(0,i,0), plane_no=(0,1,0))
geom += bm.verts[vn:] + bm.edges[en:] + bm.faces[fn:]
The script expects to start with the object in edit mode and the sample file has all mesh components selected. When the script is run the error
ValueError: geom: found the same (BMVert/BMEdge/BMFace) used multiple times
is given and then when the 3d view is updated blender crashes.The problem comes from the call to
bmesh.ops.delete
and would appear to be caused by bothgeom
andcontext
parameters being passed, while all components are selected.If context is removed or changed (values of 1,2 and 4 works) or if everything is deselected before running the script there is no problem. I think the enum for the context value should be defined in python and to me it looks like it should match the enum in https://developer.blender.org/diffusion/B/browse/master/source/blender/bmesh/intern/bmesh_operator_api.h;f667593b6a1325c62a89a6ae1ae4718833dca4d0$340 .
Also having only the listed items selected works, so you can also change the first loop to -
Related to this - the python docs for
bmesh.ops.delete
could be improved. Some clarification for the context and/or geom parameter could be added, is context meant to delete selected items or does it have to match (or subset of) the type of items in the geom list?Changed status to: 'Open'
Added subscriber: @sambler
Added subscriber: @mano-wii
Changed status from 'Open' to: 'Archived'
Actually the crash occurs because the execution of the script is being interrupted before the
bmesh.update_edit_mesh(mesh)
.Remember that the new elements created are not necessarily at the end of the array. So your code is actually repeating elements in the list.
Unfortunately the return of the
bmesh.ops.bisect_plane
does not inform the new index of the cut edges :This return is a matter for discussion... In another report.
Added subscriber: @hedgehog90-3
I posted the question on BSE.
I've seen the editmode_toggle trick used in other addons as a flush to ensure everything is as it seems. But without it, it seems bmesh.ops.bisect_plane is filling gaps in bm.verts/edges/faces that resulted from the deletion op.
Thus:
Will catch some repeated elements due to the initial deletion making Swiss cheese of my geometry.
Shouldn't there be an additional op that ensures that new geometry is appended?
(along with documentation and something in the Gotchas section)
Surely it's just a matter of removing secret gaps in the BMElemSeqs and updating indices.
Unless I'm terribly mistaken, could someone explain why this wouldn't be a welcome addition to the bmesh module?
This takes repetitive elements because the new elements are added in the middle of the list (not at the end).
Unfortunately the return of the
bmesh.ops.bisect_plane
operator is currently limited. So to get around this limitation in python is necessary to make a hack that unfortunately makes your code less efficient :\Here is the hack:
This issue was referenced by blender/blender@2b3cc24388
Changed status from 'Archived' to: 'Resolved'