I'd like to create a flat mesh and give it a thickness by bmesh. Putting together some answers seen on this forum, I thought that a script like the one below should have done the work, but it doesn't. How to make it work?
import bpy
import bmesh
me = bpy.data.meshes.new('theMesh')
ob = bpy.data.objects.new('theObject', me)
bm = bmesh.new()
bm.from_mesh(me)
ob.location = [0,0,0]
ob.show_name = True
bpy.context.scene.objects.link(ob)
#Create the mesh (in this example a very simple 4 verticies mesh)
#=======================
l=1
w=1
h=1
vertex= [0 for xi in range(4)]
vertex[0] = bm.verts.new( (-l/2, -w/2, +h/2 ))
vertex[1] = bm.verts.new( (-l/2, +w/2, +h/2 ))
vertex[2]= bm.verts.new( (+l/2, +w/2, +h/2 ))
vertex[3] = bm.verts.new( (+l/2, -w/2, +h/2 ))
for i in [0,1,2,3]:
bm.edges.new( (vertex[i], vertex[(i+1) % 4] ))
bm.faces.new( (vertex[:]) )
#========================
# Add thickness
bmesh.ops.solidify(bm, geom=[f for f in bm.faces], thickness=-h)
bm.to_mesh(me)
me.update()
The script runs without errors, but the thickness doesn't appear.
Note that if the flat mesh is created by create_grid the script works.
#Create the mesh
#=======================
bmesh.ops.create_grid(bm,size=1)
#=======================