失敗 六角形 骨格 アニメ でも 色付き
配布ファイル
https://drive.google.com/file/d/13RqAkuNesZ0MIGKfaStNJc2-hibaqlBi/view?usp=sharing
import bpy
# コレクションを作成
collection_name = "放射分布 球体"
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 math
import mathutils
# 格子点の方向数
grid_num = 12
# 球体の半径
sphere_radius = 1.0
# マテリアルを作成
mat_red = bpy.data.materials.new(name="SphereMaterialRed")
mat_red.diffuse_color = (1, 0, 0, 0.2)
mat_blue = bpy.data.materials.new(name="SphereMaterialBlue")
mat_blue.diffuse_color = (0, 0, 1, 0.2)
# 格子点に球体を配置 3以上 3だと密
for i in range(grid_num):
for j in range(grid_num):
angle = 2 * math.pi * j / grid_num
x = math.cos(angle) * i * sphere_radius * 9
z = math.sin(angle) * i * sphere_radius * 9
loc = mathutils.Vector((x, 0, z))
bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, location=loc)
obj = bpy.context.active_object
obj.name = f"Sphere_{i}_{j}"
if i < 3:
obj.data.materials.append(mat_red)
else:
obj.data.materials.append(mat_blue)