I've got a flat mesh resulting from a previous script (How to draw a PostGIS Polygon with holes into Blender using Python) :

Flat Mesh

I'd like to extrude this mesh by Region using Python (This can be done from Blender, in Edit mode, selecting the entire mesh, then from the mesh menu: Extrude --> Region)

Extrude Region

Typically, i don't want to extrude individual faces showing the internal edges of the polygon like this :

Extrude individual Faces

Below is a script extruding the active mesh, but unfortunately it's using individual faces, and i couldn't adapt it to extrude Region :

import bmesh

o = bpy.context.active_object
me = o.data
bm = bmesh.new()
faces = bm.faces[:]
for face in faces:
    r = bmesh.ops.extrude_discrete_faces(bm, faces=[face])
    bmesh.ops.translate(bm, vec=Vector((0,0,-3)), verts=r['faces'][0].verts)

Is there a way to adapt this script to extrude Region instead of individual faces ?

  • $\begingroup$ personally I would put a Solidify modifier on the 2d Surface Curve (The closed polyline) then convert to Mesh. Simple script to write if you're interested --- or simply use the Extrude parameter on the 2d Curve. (In Object Properties -> Geometry) $\endgroup$
    – zeffii
    Oct 19, 2015 at 15:06

2 Answers 2


This should do the trick, and no need to create a bmesh object to extrude all your mesh's faces:

import bpy

# Go to edit mode, face selection mode and select all faces
bpy.ops.object.mode_set( mode   = 'EDIT'   )
bpy.ops.mesh.select_mode( type  = 'FACE'   )
bpy.ops.mesh.select_all( action = 'SELECT' )

    TRANSFORM_OT_translate={"value":(0, 0, 3)}

bpy.ops.object.mode_set( mode = 'OBJECT' )

Often you can find hints about how to call operators from the info panel, and of course the tooltip. In this case they give contradictory hints but both can get be beneficial: Hints

  • $\begingroup$ This is exactly what i needed. Thank you so much Tlousky. I didn't know about that info pannel, quite useful. I was on the right track with this extrude_region_move() function but i had trouble passing the right parameters. Prior to that call, I was also missing the face selection mode, and the "select all faces" function. Thanks to your example, it now works like a charm :-) $\endgroup$
    – yoric
    Oct 19, 2015 at 14:10
  • $\begingroup$ No problem. Just have to warn the the info panel doesn't always show executed operators, but it's a good habit to check there from time to time. $\endgroup$
    – TLousky
    Oct 19, 2015 at 14:22


  • TextEditor -> Templates -> Python -> BMesh Simple
  • TextEditor -> Templates -> Python -> BMesh Simple EditMode

for an example of how to get the bmesh from an object in Object Mode or Edit Mode.

Here's a low level way to do the extrusion using bmesh.ops.solidify. This example will extrude only those faces that are selected.

import bpy
import bmesh

me = bpy.context.object.data

bm = bmesh.new()   # create an empty BMesh
bm.from_mesh(me)   # fill it in from a Mesh

bmesh.ops.solidify(bm, geom=[f for f in bm.faces if f.select], thickness=0.3)

bm.free()  # free and prevent further access

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .