Blender初心者が最初に覚えるべき内容をまとめたページは、このリンクにあります。
以下は、BlenderのPythonスクリプトで、meshesオブジェクトを生成するコード紹介です。
(GUI操作なしで、スクリプトだけで生成しています。)
import sys sys.path.append('D:\\work') from importlib import reload import beditsub #import ochawan #reload( ochawan ) import os import bpy import bmesh import mathutils for obj in bpy.data.objects:# 'Camera' と 'Light' 以外を全て削除する if obj.name=='Camera' or obj.name=='Light': continue bpy.data.objects.remove( obj ) bpy.ops.mesh.primitive_cylinder_add(vertices=32,radius=0.05,depth=0.05)#円柱を追加 obj= bpy.data.objects['円柱'] beditsub.deselect_all_elements(obj) # objの内部を全て非選択にする。 # 底面からの編集--------------------------------------------------------------------------------- face_idx, _ =beditsub.get_index_closest_face(obj, mathutils.Vector((0.0, 0.0, -2.0)) ) # 底の面を選択 bpy.ops.transform.resize(value=(0.6, 0.6, 1))# サイズ変更処理(デフォルト部を省略) bpy.ops.mesh.inset(thickness=0.001) # 選択した面に新しい面を差し込む bpy.ops.transform.translate( value=(0, 0, -0.01) ) #Z軸を移動 bpy.ops.transform.resize(value=(1.2, 1.2, 1))# サイズ変更処理 bpy.ops.mesh.inset(thickness=0.007) # 選択した面に新しい面を差し込む bpy.ops.transform.translate( value=(0, 0, 0.007) ) #Z軸を移動 beditsub.deselect_all_elements(obj) # objの内部を全て非選択にする。 edge_idx, _ =beditsub.get_index_closest_edge(obj, mathutils.Vector((0.0, 0.0, -2.0)) ) # 底の辺を選択 bpy.ops.mesh.loop_multi_select(ring=False) # # 選択した辺より、「辺ループ選択」をを行う bpy.ops.mesh.bevel(offset=0.01, offset_pct=0, segments=3, release_confirm=False) # ベベル # 上面の編集--------------------------------------------------------------------------------- beditsub.deselect_all_elements(obj) # objの内部を全て非選択にする。 edge_idx, _ =beditsub.get_index_closest_face(obj, mathutils.Vector((0.0, 0.0, 2.0)) ) # 上の面を選択 bpy.ops.mesh.inset(thickness=0.022) # 選択した面に新しい面を差し込む bpy.ops.transform.translate( value=(0, 0, -0.048) ) #Z軸を移動 beditsub.deselect_all_elements(obj) # objの内部を全て非選択にする。 edge_idx, _ =beditsub.get_index_closest_edge(obj, mathutils.Vector((0.0, 0.0, 2.0)) ) # トップの辺を選択 bpy.ops.mesh.loop_multi_select(ring=False) # # 選択した辺より、「辺ループ選択」をを行う bpy.ops.mesh.bevel(offset=0.01, offset_pct=0, segments=3, release_confirm=False) # ベベル # 腹部を切って、膨らませる編集--------------------------------------------------------------------- #beditsub.deselect_all_elements(obj) # objの内部を全て非選択にする。 bpy.ops.mesh.edges_select_sharp() # 辺の選択状態に bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.bisect(# 引数の平面で、切断する(選択対象を切断) plane_co=(0.0, 0.0, -0.009), # カット平面の基準点 plane_no=(0.0, 0.0, 1.0), # カット平面の法線ベクトル ) bpy.ops.transform.resize(value=(1.1, 1.1, 1))# 上記の切断面を膨らませる # 尖がらせたい頂点を選択して、移動でする------------------------------------------------------------ beditsub.deselect_all_elements(obj) # objの内部を全て非選択にする。 target_location=mathutils.Vector((0.0, -2.0, 2.0)) # 尖がらせる方向の位置 vert_idx, _ =beditsub.get_index_closest_vert(obj, target_location ) # 目標の位置に近い頂点を選択 target_location=beditsub.getVector(obj, vert_idx)#上記で選択した頂点の座標取得 print(target_location) exclude_idx=[vert_idx] for n in range(3): # 3つの頂点を追加選択 vert_idx, _ =beditsub.get_index_closest_vert(obj, target_location, exclude_idx ) # 目標の位置に近い頂点を選択 exclude_idx.append(vert_idx) bpy.ops.transform.translate(value=(0, -0.02, 0))# 選択(ここでは頂点)の移動この実行は、上記のochawan.pyとbeditsub.pyが「D:\work」の位置に配置する必要があります。