刚刚接触blender 希望对一些特定的模型做一些编辑操作,刚刚测试了一下挤压命令,在这里mark 一下
import bpy
import bmesh
//切换到编辑模式下
bpy.ops.object.mode_set( mode = 'EDIT' )
bpy.ops.mesh.select_mode( type = 'FACE' )
bpy.ops.mesh.select_all( action = 'SELECT' )
//获取plane模型下的height 属性
height= bpy.data.objects["Plane"]["height"]
print(height)
//拉伸z轴
bpy.ops.mesh.extrude_region_move(
TRANSFORM_OT_translate={"value":(0, 0, height)}
)
//切回OBJECT模式
bpy.ops.object.mode_set( mode = 'OBJECT' )
批量生成模型高度
import bpy
for obj in bpy.data.objects:
bpy.context.view_layer.objects.active = obj
height = obj["height"]
print(height)
# 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' )
bpy.ops.mesh.extrude_region_move(
TRANSFORM_OT_translate={"value":(0, 0, height )}
)
bpy.ops.object.mode_set( mode = 'OBJECT' )
import bpy
import bmesh
#切换到编辑模式下
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_mode(type= 'FACE')
bpy.ops.mesh.select_all( action = 'SELECT' )
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value":(0,0,5)} )
print(bpy.context.view_layer.objects.active)
#切回OBJECT模式
bpy.ops.object.mode_set( mode = 'OBJECT' )