投稿

ラベル(原型)が付いた投稿を表示しています

原型 立方体を 基準に 3つの平行な正方形

イメージ
  Blender Pythonスクリプトで、y=-1, 0, 1の3つの位置にあるx=0、z=0を中心とした正方形を作成 # コレクションを作成 import bpy collection_name = "正方形 3つ" if collection_name not in bpy.data.collections:     zionad_collection = bpy.data.collections.new(collection_name)     bpy.context.scene.collection.children.link(zionad_collection) else:     zionad_collection = bpy.data.collections[collection_name] import bpy # 正方形の中心 center = (0, 0, 0) # 正方形の大きさ size = 2.0 # 正方形の座標 square_vertices = [     (center[0] - size/2, center[1], center[2] - size/2),     (center[0] + size/2, center[1], center[2] - size/2),     (center[0] + size/2, center[1], center[2] + size/2),     (center[0] - size/2, center[1], center[2] + size/2) ] square_edges = [(0,1), (1,2), (2,3), (3,0)] square_faces = [(0,1,2,3)] # 正方形を作成する関数 def create_square(x, y, z):     # Meshデータの作成     mesh = bpy.data.meshes.new("Square")     # 座標を変換して、正方形をx,y,zの位置に移動     vert...

原型 立方体と 頂点の基本セット

イメージ
  import bpy # 立方体を作成 bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, location=(0,0,0)) cube = bpy.context.object cube.name = "Cube" # 立方体の頂点の座標 vertex_coords = [(1,1,1), (-1,1,1), (-1,-1,1), (1,-1,1), (1,1,-1), (-1,1,-1), (-1,-1,-1), (1,-1,-1)] # 頂点に球体を作成 for i in range(8):     bpy.ops.mesh.primitive_uv_sphere_add(radius=0.1, enter_editmode=False, location=vertex_coords[i])     ball = bpy.context.object     ball.name = "Ball." + str(i+1)

原型 球体36 xz 縦 正方形 60x60 平面分布

イメージ
   #色付き球体 36個 60x60 平面分布 import bpy # コレクションを作成 collection_name = "球体 xz 縦 正方形" if collection_name not in bpy.data.collections:      sphere _collection = bpy.data.collections.new(collection_name)     bpy.context.scene.collection.children.link( sphere _collection) else:      sphere _collection = bpy.data.collections[collection_name] import bpy import mathutils # 格子点のサイズ grid_size = 10 # 格子点の数 grid_num = 6 # 球体の半径 sphere_radius = 1.0 # マテリアルを作成 mat = bpy.data.materials.new(name="SphereMaterial") mat.diffuse_color = (0.40, 0.7, 0.5, 0.3) # 格子点に球体を配置 for i in range(grid_num):     for j in range(grid_num):         x = (i - (grid_num - 1) / 2) * grid_size         z = (j - (grid_num - 1) / 2) * grid_size         loc = mathutils.Vector((x, 0, z))         bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, location=loc)         ob...

原型 球体36 xy 横 正方形 60x60 平面分布

イメージ
  #色付き球体 36個 60x60 平面分布 import bpy # コレクションを作成 collection_name = "球体 xy 横 正方形" if collection_name not in bpy.data.collections:      sphere _collection = bpy.data.collections.new(collection_name)     bpy.context.scene.collection.children.link( sphere _collection) else:      sphere _collection = bpy.data.collections[collection_name] import bpy import mathutils # 格子点のサイズ grid_size = 10 # 格子点の数 grid_num = 6 # 球体の半径 sphere_radius = 1.0 # マテリアルを作成 mat = bpy.data.materials.new(name="SphereMaterial") mat.diffuse_color = (0.40, 0.2, 0.5, 0.3) # 格子点に球体を配置 for i in range(grid_num):     for j in range(grid_num):         x = (i - (grid_num - 1) / 2) * grid_size         y = (j - (grid_num - 1) / 2) * grid_size         loc = mathutils.Vector((x, y, 0))         bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, location=loc)         obj = bpy...