I'm just messing around with bmesh and was trying to create a script that would extrude the edges I mark as sharp. Here's my code:
import bpy
import bmesh
from mathutils import Vector
ob = bpy.context.object
me = ob.data
bm = bmesh.from_edit_mesh(me)
selected_verts = [v for v in bm.faces if v.select]
verts_to_extrude = []
for e in bm.edges:
if not e.smooth:
verts_to_extrude.append(e)
bmesh.ops.extrude_edge_only(bm, edges=verts_to_extrude)
bmesh.update_edit_mesh(bpy.context.object.data)
Here is what it does:
Before:
After:
Note: the code does not move the selected vertices, I just moved them out of the way so you could see what its doing.
It is doing what I want in that it is extruding the vertices marked sharp, but it leaves the original vertices I had selected, selected. Is there any way to make it so that it selects the extruded vertices and deselects the vertices I had selected before the operation?
bpy.ops.mesh.extrude_edges_indiv()
instead ofbmesh.ops.extrude_edge_only(bm, edges=verts_to_extrude)
. Therefore you must select the edges beforehand rather than store them in a list. Not sure if that solves your problem so I didn't write an answer. $\endgroup$