bmesh.ops.extrude_discrete_faces
takes a list of faces and extrudes them, leaving them in the original place with new joining geometry. If we take the ['faces']
part of the data returned by extrude_discrete_faces
we have a list of faces that have been extruded, these are the 'original' faces only, not the extra joining faces.
For each of these extruded faces we take the face normal and multiply it by the distance you wish to move the face and use that in bmesh.ops.translate
to position them where you want.
import bpy
import bmesh
# sample set for cube
extrude_values = [0.1,0.2,0.3,0.4,0.5,0.6]
obj = bpy.context.active_object
bm = bmesh.new()
bm.from_mesh(obj.data,face_normals=True)
extrude_faces = bmesh.ops.extrude_discrete_faces(bm, faces=bm.faces)['faces']
for f_idx in range(len(extrude_faces)):
dr = extrude_faces[f_idx].normal * extrude_values[f_idx]
bmesh.ops.translate(bm, verts=extrude_faces[f_idx].verts, vec=dr)
bm.to_mesh(obj.data)
bm.free()
obj.data.update()
list(bpy.context.object.data.polygons)
seems to give the faces. Andbpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={ "constraint_orientation": 'NORMAL', "value": (x, y, z)})
extrudes the face that is selected. $\endgroup$