I followed this and ended up with a closed mesh.
import bpy,bmesh
import mathutils
from mathutils import Vector
bm = bmesh.from_edit_mesh( bpy.context.object.data )
operate_faces=[a for a in bm.select_history]
n = Vector((0,0,0))
for i in operat_faces:
n += i.normal
r=bmesh.ops.extrude_face_region(bm,geom=operat_faces)
verts = [e for e in r['geom'] if isinstance(e, bmesh.types.BMVert)]
z = mathutils.Vector((0,0,1))
axis = n.cross(z)
angle = n.angle(z)
R = mathutils.Matrix.Rotation(angle,4,axis)
bmesh.ops.translate(bm, vec = Vector((0,0,.3)),space=R,verts = verts )
#bmesh.ops.delete(bm, geom=operat_faces, context=5)
bmesh.update_edit_mesh( bpy.context.object.data )
but I want the original faces to disappear, so I used
bmesh.ops.delete(bm, geom=operate_faces, context=5)
to delete the faces. Is there a better way?
PS: I tried to use extrude_discrete_faces()
, but the faces that extruded were not connected.