2023年7月30日日曜日
20230731b 光時計セット 追加 円板 メッシュ マテリアル
2023731a 21個 球体 等間隔 2単位長さ
a
# コレクションを作る 重複の場合 作らない
import bpy
# List of collection names
collection_names = [
"axis_x_balls",
"axis_y_balls",
"axis_z_balls",
"ba_X=0.5 balls",
"ba_X=1 balls",
"ba_(√3)/2 balls",
"xyz 軸 balls"
]
# Function to create a new collection if it doesn't exist
def create_collection_if_not_exists(name):
if name not in bpy.data.collections:
collection = bpy.data.collections.new(name)
bpy.context.scene.collection.children.link(collection)
# Create collections
for name in collection_names:
create_collection_if_not_exists(name)
blender python
21個の球体を作る
球体の大きさ0.06
指定位置の間に等間隔に配置する
(x,y,z)
=(0,1、0)から
(0,-1、0)
連番で名前をつける "ba_a連番(0,1、0)(0,-1、0)ball”
位置は 小数点1桁まで表示
連番で名前をつける "ba_a連番(0,1、0)(0,-1、0)ball”
連番で名前をつける "ba_b連番(0,1、0)(0,-1、0)ball”
のように 名前を付ける
(x,y,z)
=(0,1、0)から(0,-1、0)
(x,y,z)
=(-1,0、0)から(1,0、0)
(x,y,z)
=(0,0、ー1)から(0,0、1)
(x,y,z)
=(1,1、0)から(1,-1、0)
import bpy
# Function to create a new sphere object and rename it with a sequential number
def create_sphere_object(location, name):
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.06, location=location)
obj = bpy.context.active_object
obj.name = name
# Number of spheres to create
num_spheres = 21
# Define the ranges for each axis
ranges = [
((0, 1, 0), (0, -1, 0)),
((-1, 0, 0), (1, 0, 0)),
((0, 0, -1), (0, 0, 1))
]
# Loop through the ranges and create sphere objects with the desired prefixes
prefixes = ["axis_y", "axis_x", "axis_z"]
for i, (start_position, end_position) in enumerate(ranges):
prefix = prefixes[i]
step_size = [(end_position[j] - start_position[j]) / (num_spheres - 1) for j in range(3)]
for j in range(num_spheres):
x = round(start_position[0] + j * step_size[0], 1)
y = round(start_position[1] + j * step_size[1], 1)
z = round(start_position[2] + j * step_size[2], 1)
object_name = f"{prefix}_{str(j+1).zfill(3)}({x},{y},{z})_({x},{-y},{z})_ball"
create_sphere_object((x, y, z), object_name)
基本系 配布 001 単位円 torus と xyz軸 円柱
https://drive.google.com/file/d/1adh0pC0n5MUfaPnsQcab8CnTvHu_JqLg/view?usp=drive_link
基本系 配布 002 単位2長さ balls
https://drive.google.com/file/d/1vyg5oFWmw_TK8nwp5TmVSfLH94I6rTaY/view?usp=drive_link
基本系 配布 003 単位2長さ balls 光時計セット
https://drive.google.com/file/d/1u2Rn_nVBcewe39Vokua9C5n25cdivyyL/view?usp=drive_link
blender 基本系 配布 カタログ 2023 - zionad_mainのブログ https://mokuji000zionad.hatenablog.com/entry/2023/07/31/095208
2023年7月29日土曜日
20230730a 単位円を貫く円柱
目次 blender 部品 2023 - zionad_mainのブログ
blender 使い方 目次 2023 - zionad_mainのブログ
円柱を作る
長さ 4
中心 000
半径 0.03
x軸
y軸
z軸
合計 3つの円柱を作る
import bpy
# Function to create a cylinder along the specified axis
def create_cylinder(axis, name):
bpy.ops.mesh.primitive_cylinder_add(vertices=32, radius=0.03, depth=4, location=(0, 0, 0))
cylinder = bpy.context.object
if axis == "x":
cylinder.rotation_euler = (1.5708, 0, 0) # 90 degrees in radians around X axis
elif axis == "y":
cylinder.rotation_euler = (0, 1.5708, 0) # 90 degrees in radians around Y axis
cylinder.name = name
# Create cylinders along each axis
create_cylinder("y", "名称X軸円柱")
create_cylinder("x", "名称y軸円柱")
create_cylinder("z", "Z軸円柱")
20230730a 単位円の トーラス
aaaaa
目次 blender 部品 2023 - zionad_mainのブログ
blender 使い方 目次 2023 - zionad_mainのブログ
xy平面に描いたトーラスを zx平面と yz平面にも描いて
import bpy
# Function to create a torus in the specified plane
def create_torus(plane):
bpy.ops.mesh.primitive_torus_add(align='WORLD', location=(0, 0, 0), rotation=(0, 0, 0),
major_radius=1, minor_radius=0.04, major_segments=48, minor_segments=12)
torus = bpy.context.object
if plane == "xy":
torus.rotation_euler = (0, 0, 0)
elif plane == "zx":
torus.rotation_euler = (1.5708, 0, 0) # 90 degrees in radians around X axis
elif plane == "yz":
torus.rotation_euler = (0, 1.5708, 0) # 90 degrees in radians around Y axis
torus.name = f"Torus {plane.upper()} Plane"
# Create tori in each plane
create_torus("xy")
create_torus("yz")
create_torus("zx")
2023年7月28日金曜日
202230729c 3本の線路
blender python
球体を作る
球体半径 0.05
Z=0の
y=0
X=-2 から X=+2 に
等間隔で 21個の球体を作る
球体の名前は
”rail Y=0" で 連番
y=ー√3
y=-2にも 同様にして
import bpy
import math
def create_sphere(x_pos, y_pos, name):
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.05, location=(x_pos, y_pos, 0))
sphere = bpy.context.object
sphere.name = name
# 等間隔で21個の球体を作成
for i in range(21):
x_pos = -2.0 + (i * 0.2) # X座標を計算
x_pos_rounded = round(x_pos, 1) # 小数点以下1桁までに丸める
name = f"rail Y=0 {x_pos_rounded}" # 球体の名前を生成
create_sphere(x_pos, 0, name)
# Y軸が"-√3"と"-2"の位置にも球体を作成
y_positions = [round(-math.sqrt(3), 1), -2] # "-√3"の部分を小数点以下1桁までに丸める
for y_pos in y_positions:
for i in range(21):
x_pos = -2.0 + (i * 0.2) # X座標を計算
x_pos_rounded = round(x_pos, 1) # 小数点以下1桁までに丸める
name = f"rail Y={y_pos} {x_pos_rounded}" # 球体の名前を生成
create_sphere(x_pos, y_pos, name)
ああああ
202230729b 円中心の球体point mark 半径2の円
球体を作る
円中心に 半径0.1
import bpy
# 球体を作成する位置のリスト
positions = [
(0, 0, 0),
(0, -2, 0),
(1, -3**0.5, 0),
(-1, -3**0.5, 0)
]
# ここからBlenderの処理
# シーンに追加
scene = bpy.context.scene
# 球体を作成
for i, position in enumerate(positions, start=1):
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.1, location=position)
# 球体の名前を設定
sphere = bpy.context.active_object
sphere.name = f"Sphere_(x={position[0]:.1f}, y={position[1]:.1f}, z={position[2]:.1f})_{i}番"
202230729a 半径2の円 と 今回のコレクショ名
あ
blender python
円を作る
円の半径2
円の中心は
0,0,0
0,-2,0
1,-√3,0
-1,-√3,0
centers = [
(0, 0, 0),
(0, 2, 0),
(1, -math.sqrt(3), 0),
(-1, -math.sqrt(3), 0)
]
import bpy
import math
import bmesh
# 円の半径
radius = 2.0
# 4つの円の位置
positions = [
(0, 0, 0),
(0, -2, 0),
(1, -math.sqrt(3), 0),
(-1, -math.sqrt(3), 0)
]
# 4つの色を用意(より薄い青)
colors = [
(0.4, 0.8, 1.0, 1.0),
(0.3, 0.6, 1.0, 1.0),
(0.2, 0.4, 1.0, 1.0),
(1.0, 0.4, 0.3, 1.0)
]
# 4つの円を作成し、位置と名前と色を設定
for i, (position, color) in enumerate(zip(positions, colors)):
x, y, z = position
name = f"Circle_(x={x:.1f}, y={y:.1f}, z={z:.1f})"
# 新しいメッシュを作成
mesh = bpy.data.meshes.new(f"{name}_Mesh")
obj = bpy.data.objects.new(name, mesh)
# シーンに追加
scene = bpy.context.scene
scene.collection.objects.link(obj)
# メッシュを作成
bm = bmesh.new()
bmesh.ops.create_circle(bm, cap_ends=True, cap_tris=False, segments=64, radius=radius)
bm.to_mesh(mesh)
bm.free()
# オブジェクトの位置を設定
obj.location = position
# マテリアルを作成しオブジェクトに割り当てる
mat = bpy.data.materials.new(name=f"{name}_Material")
mat.use_nodes = False # ノードを使用しない
mat.diffuse_color = color
obj.data.materials.append(mat)







