2
$\begingroup$

The script is simple:

import bpy, bmesh

mesh = bpy.context.edit_object.data
bm = bmesh.from_edit_mesh(mesh)
geom = [e for e in bm.verts[:] + bm.edges[:] + bm.faces[:] if e.select]

cut_layer = bm.edges.layers.int.new('cut')
ret = bmesh.ops.bisect_plane(bm, geom=geom , plane_co=(0,1,0), plane_no=(0, 1, 0))
bm.edges.layers.int.remove(cut_layer)

bmesh.update_edit_mesh(mesh)

I get the error:

TypeError: geom: 8 BMEdge has been removed

Here's an example blend file:

https://drive.google.com/open?id=0B9DFPZBPKp6ARjE5NXgzSTU0eDQ

Can anyone explain what's going wrong here? I know the function itself looks a little pointless but that's because I've boiled the problem down to it's simplest form. Why does the operation have a problem with the new edge layer I've added? I can't find anything online about this...

$\endgroup$

1 Answer 1

1
$\begingroup$

Assign your int layer before you assign geometry. PS took out verts from bisectable geometry.

import bpy, bmesh

mesh = bpy.context.edit_object.data
bm = bmesh.from_edit_mesh(mesh)
cut_layer = bm.edges.layers.int.new('cut')
geom = [e for e in bm.edges[:] + bm.faces[:] if e.select]

ret = bmesh.ops.bisect_plane(bm, geom=geom , plane_co=(0,1,0), plane_no=(1, 0, 0))
bm.edges.layers.int.remove(cut_layer)

bmesh.update_edit_mesh(mesh)
$\endgroup$
2
  • $\begingroup$ This is a bit of a problem as I'm creating my own bmesh operations as it were, which make no reference to selected elements, but receive parameters as lists of geometry (just like the built-in bmesh ops). Is there some way I can keep the order of my original code while fixing the problem? Even if it means iterating over all the input geom after adding the new layer. $\endgroup$
    – hedgehog90
    Commented Mar 12, 2017 at 12:40
  • $\begingroup$ Thank you batFINGER, Wouldn't have guessed from the error msg (TypeError: geom: 0 BMVert has been removed) that it had something to do with a custom data layer. $\endgroup$ Commented Jan 25, 2023 at 10:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .