import bpy
import bmesh
for item in bpy.data.meshes:
bpy.data.meshes.remove(item)
bpy.ops.mesh.primitive_cube_add()
bpy.ops.object.duplicate_move()
bpy.ops.transform.translate(value=(0,0,-2))
bpy.ops.object.mode_set(mode='EDIT')
bm = bmesh.from_edit_mesh(bpy.data.meshes['Cube.001'])
for v in bm.verts:
if v.co.z < -0.5:
v.select_set(True)
else:
v.select_set(False)
bpy.ops.transform.translate(value=(0,0,-1))
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.transform.resize(value=(1,0.5,1))
bpy.ops.object.duplicate_move()
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.transform.translate(value=(1,0,0))
bm = bmesh.from_edit_mesh(bpy.data.meshes['Cube.002'])
for v in bm.verts:
if v.co.x < 1:
v.select_set(True)
else:
v.select_set(False)
bpy.ops.transform.translate(value=(1,0,0))
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.modifier_add(type='MIRROR')
bpy.ops.object.duplicate_move()
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.transform.translate(value=(-1,0,-3))
参考