import bpy
import bmesh
import math
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))
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects['Cube'].name = 'Head'
bpy.data.meshes['Cube'].name = 'Head'
bpy.data.objects['Cube.001'].name = 'Body'
bpy.data.meshes['Cube.001'].name = 'Body'
bpy.data.objects['Cube.002'].name = 'Arm'
bpy.data.meshes['Cube.002'].name = 'Arm'
bpy.data.objects['Cube.003'].name = 'Leg'
bpy.data.meshes['Cube.003'].name = 'Leg'
bpy.context.view_layer.objects.active = bpy.data.objects['Arm']
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.transform.rotate(value=math.pi/2,orient_axis='Y')
bpy.ops.transform.translate(value=(1,0,1))
bm = bmesh.from_edit_mesh(bpy.data.meshes['Arm'])
for e in bm.edges:
if e.verts[0].co[0] != e.verts[1].co[0]:
e.select_set(True)
else:
e.select_set(False)
bpy.ops.mesh.subdivide(number_cuts=5)
for e in bm.edges:
if 1.2 < e.verts[0].co[0] < 1.7 and 1.2 < e.verts[1].co[0] < 1.7:
e.select_set(True)
else:
e.select_set(False)
bpy.ops.mesh.dissolve_edges()
bpy.context.view_layer.objects.active = bpy.data.objects['Leg']
bpy.ops.object.mode_set(mode='EDIT')
bm = bmesh.from_edit_mesh(bpy.data.meshes['Leg'])
for e in bm.edges:
if e.verts[0].co[2] != e.verts[1].co[2]:
e.select_set(True)
else:
e.select_set(False)
bpy.ops.mesh.subdivide(number_cuts=5)
for e in bm.edges:
if -2.7 < e.verts[0].co[2] < -2.2 and -2.7 < e.verts[1].co[2] < -2.2:
e.select_set(True)
else:
e.select_set(False)
bpy.ops.mesh.dissolve_edges()
bpy.context.view_layer.objects.active = bpy.data.objects['Body']
bpy.ops.object.mode_set(mode='EDIT')
bm = bmesh.from_edit_mesh(bpy.data.meshes['Body'])
for e in bm.edges:
if e.verts[0].co[2] != e.verts[1].co[2]:
e.select_set(True)
else:
e.select_set(False)
bpy.ops.mesh.subdivide(number_cuts=2)
bpy.context.view_layer.objects.active = bpy.data.objects['Arm']
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.modifier_apply(modifier="Mirror")
bpy.context.view_layer.objects.active = bpy.data.objects['Leg']
bpy.ops.object.mode_set(mode='OBJECT')
bpy.context.object.modifiers["Mirror"].use_mirror_merge = False
bpy.ops.object.modifier_apply(modifier="Mirror")
参考