I get geometry from bisecting some mesh bm_tmp
by a plane and I want to copy/append the resulting geometry r['geom_cut']
(only the edges and vertices of bisection) to another bmesh bm
. I solved it by the following snippet, but I was wondering if there is a better and more efficient way to copy geometry to another bmesh
import bpy
import bmesh
bm_tmp = bmesh.new()
bmesh.ops.create_monkey(bm_tmp)
geom = bm_tmp.verts[:] + bm_tmp.edges[:] + bm_tmp.faces[:]
r = bmesh.ops.bisect_plane(bm_tmp, geom=geom,
plane_co=(0, 0, 0), plane_no=(0, 0, 1))
# Get all the vertices and edges
verts = [v for v in r['geom_cut'] if isinstance(v, bmesh.types.BMVert)]
edges = [e for e in r['geom_cut'] if isinstance(e, bmesh.types.BMEdge)]
# Copy geometry
bm = bmesh.new()
vertmap = {}
for v in verts:
new_vert = bm.verts.new(v.co)
vertmap[v.index] = new_vert
for e in edges:
idx0, idx1 = e.verts[0].index, e.verts[1].index
bm.edges.new([vertmap[idx0], vertmap[idx1]])
I tried bmesh.ops.duplicate(bm_tmp, geom=r['geom_cut'], dest=bm)
but it is not implemented yet: NotImplementedError: duplicate: keyword "dest" type 4 not working yet!
for Blender 2.79.