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$
0
$\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$
  • $\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 Mar 12 '17 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.