Today's challenge is the extrusion function. Even if I search for "extrude blender 2.8 python" etc., it seems that there are few codes using extrude in blender 2.8 (2.9) in both English and Japanese. One of the few materials is the suzulang material "Making arrows with Blender 2.8 python". Read this carefully. Interpret that if you enter a number like step 1 oshidashi part in "Blender 2.8 Make an arrow with python" extrude_region_move (TRANSFORM_OT_translate = {"value": [1.0, 0.0, 3.0]}) , I managed to do it by trial and error from there I succeeded in extruding one side of the Cube and repeating it.
import bpy
import math
import bmesh
bpy.ops.mesh.primitive_cube_add(location=(1,0,3), size = 2) # === create a cube
#Switch to edit mode.
bpy.ops.object.mode_set(mode='EDIT')
#Deselect all meshes.
bpy.ops.mesh.select_all(action='DESELECT')
'''Switch to face mode,One side...oshidashi '''
#Set to face mode.
bpy.ops.mesh.select_mode(type="FACE")
#Instantiation of bmesh object.
b_mesh = bmesh.from_edit_mesh(bpy.context.object.data)
b_mesh.faces.ensure_lookup_table()
b_mesh.faces[3].select = True # === face number (3) south face
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value":[ -0.5 , -1.0 , 0.5]} )
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value":[ -0.5 , -1.0 , -0.5]} )
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value":[ -0.5 , -1.0 , 0.5]} )
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value":[ -0.5 , -1.0 , -0.5]} )
Recommended Posts