bmesh - extrude face and end up with closed mesh When you extrude the only face of a plane via the GUI you get a (closed) cube. If you do the same thing using bmesh you get a cube that is open on the bottom side.

 

I am trying to achieve the normal result through bmesh. (using regular operators is not an option because the mesh is still not linked to the scene). Right now I duplicate the original face before extrusion, extrude, and then remove doubles.

allfaces = bm.faces[:]
bmesh.ops.duplicate(bm, geom=allfaces)
r = bmesh.ops.extrude_discrete_faces(bm, faces=allfaces)
bmesh.ops.translate(bm, vec=Vector((0,0,height)), verts=r['faces'][0].verts)
bmesh.ops.remove_doubles(bm, verts=bm.verts[:], dist=0.01)


This however doesn't strike me as a very elegant way to do it. Is there some other way?
You don't need to duplicate the geometry prior to extruding (this will remove the need for removing doubles as well), and using bmesh.ops.extrude_face_region is what you're looking for to generate a closed mesh from the extruded face/s.



This worked code fine with a 1-face plane with its sole face selected in edit mode:

import bpy, bmesh
from mathutils import Vector

bm      = bmesh.from_edit_mesh( bpy.context.object.data )
newGeom = bmesh.ops.extrude_face_region( bm, geom = bm.faces, use_select_history = True )

bmesh.ops.translate( bm, vec = Vector((0,0,1)), verts = bm.select_history[0].verts )

bmesh.update_edit_mesh( bpy.context.object.data )