2023年7月21日金曜日

20230722 上書き 球体 コピー

 



コレクション名 日本語で

作って


" Z=-1” 

" Z=0” 

" Z=+1” 

" Z=+5” 




# 球体の半径

sphere_radius = 0.1


" Z=-1” 


" Z=0” 


" Z=+1” 


" Z=+5” 


Zの位置に

y=0で


X=-1

X=0

X=+1


合計 12個の球体作って


名前は X=-1なら ”左”連番で

X=0 なら ”中央”

X=1なら ”右”









" Z=ー5” にも 作って 





import bpy


# 正方形のサイズと中心位置のリスト

squares = [

    {"size": 2, "location": (0, 0, 5)},

    {"size": 2, "location": (0, 0, 1)},

    {"size": 2, "location": (0, 0, 0)},

    {"size": 2, "location": (0, 0, -1)}

]


# 球体の半径

sphere_radius = 0.1


# 正方形を作成する関数

def create_square(size, location):

    bpy.ops.mesh.primitive_plane_add(size=size, location=location)


# 球体を作成する関数

def create_sphere(radius, location, name):

    bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, location=location)

    bpy.context.active_object.name = name


# 正方形と球体を作成

for i, square_data in enumerate(squares):

    create_square(square_data["size"], square_data["location"])

    create_sphere(sphere_radius, square_data["location"], f"Center_{i}")

    

    # 左側に球体を作成

    left_location = (square_data["location"][0] - 1, square_data["location"][1], square_data["location"][2])

    create_sphere(sphere_radius, left_location, f"Left_{i}")


    # 右側に球体を作成

    right_location = (square_data["location"][0] + 1, square_data["location"][1], square_data["location"][2])

    create_sphere(sphere_radius, right_location, f"Right_{i}")





import bpy


# 正方形のサイズと中心位置のリスト

squares = [

    {"size": 2, "location": (0, 0, 5)},

    {"size": 2, "location": (0, 0, 1)},

    {"size": 2, "location": (0, 0, 0)},

    {"size": 2, "location": (0, 0, -1)}

]


# 球体の半径

sphere_radius = 0.1


# 正方形を作成する関数

def create_square(size, location):

    bpy.ops.mesh.primitive_plane_add(size=size, location=location)


# 球体を作成する関数

def create_sphere(radius, location, name):

    bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, location=location)

    bpy.context.active_object.name = name


# 正方形と球体を作成

for i, square_data in enumerate(squares):

    create_square(square_data["size"], square_data["location"])

    create_sphere(sphere_radius, square_data["location"], f"Center_{i}")

    

    # 左側に球体を作成

    left_location = (square_data["location"][0] - 1, square_data["location"][1], square_data["location"][2])

    create_sphere(sphere_radius, left_location, f"Left_{i}")


    # 右側に球体を作成

    right_location = (square_data["location"][0] + 1, square_data["location"][1], square_data["location"][2])

    create_sphere(sphere_radius, right_location, f"Right_{i}")




import bpy


# 正方形のサイズと中心位置のリスト

squares = [

    {"size": 2, "location": (0, 0, 5)},

    {"size": 2, "location": (0, 0, 1)},

    {"size": 2, "location": (0, 0, 0)},

    {"size": 2, "location": (0, 0, -1)}

]


# 球体の半径

sphere_radius = 0.1


# 正方形を作成する関数

def create_square(size, location):

    bpy.ops.mesh.primitive_plane_add(size=size, location=location)


# 球体を作成する関数

def create_sphere(radius, location, name):

    bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, location=location)

    bpy.context.active_object.name = name


# 正方形と球体を作成

for i, square_data in enumerate(squares):

    create_square(square_data["size"], square_data["location"])

    create_sphere(sphere_radius, square_data["location"], f"Center_{i}")

    

    # 左側に球体を作成

    left_location = (square_data["location"][0] - 1, square_data["location"][1], square_data["location"][2])

    create_sphere(sphere_radius, left_location, f"Left_{i}")


    # 右側に球体を作成

    right_location = (square_data["location"][0] + 1, square_data["location"][1], square_data["location"][2])

    create_sphere(sphere_radius, right_location, f"Right_{i}")




import bpy


sphere_radius = 0.1


# 球体を作成

def create_sphere(name, position):

    bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, location=position)

    obj = bpy.context.active_object

    obj.name = name

    return obj


# 球体の名前を設定

def get_sphere_name(x, z):

    if x == -1:

        return f"左{z:02}"

    elif x == 0:

        return f"中央{z:02}"

    else:

        return f"右{z:02}"


# 12個の球体を作成

z_positions = [-1, 0, 1, 5]

x_positions = [-1, 0, 1]

sphere_counter = 1


for z in z_positions:

    for x in x_positions:

        name = get_sphere_name(x, z)

        position = (x, 0, z)

        create_sphere(name, position)

        sphere_counter += 1







っっっz