import bpy
import math
# Clear existing mesh objects
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.object.select_by_type(type='MESH')
bpy.ops.object.delete()
# Initial settings
torus_major_radius = 1.0
torus_minor_radius = 0.03
sphere_radius = 0.07
animation_duration = 20
frame_rate = bpy.context.scene.render.fps
clockwise = True
# Create torus 1
bpy.ops.mesh.primitive_torus_add(align='WORLD', major_radius=torus_major_radius, minor_radius=torus_minor_radius, location=(0, 0, 0))
torus1 = bpy.context.active_object
# Create sphere 1
bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, location=(-1, 0, 0))
sphere1 = bpy.context.active_object
sphere1.parent = torus1
# Create torus 2
bpy.ops.mesh.primitive_torus_add(align='WORLD', major_radius=torus_major_radius, minor_radius=torus_minor_radius, location=(0, 0, 0))
torus2 = bpy.context.active_object
# Create sphere 2
bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, location=(0, 1, 0))
sphere2 = bpy.context.active_object
sphere2.parent = torus2
# Calculate the midpoint between sphere centers
midpoint = ((sphere1.location.x + sphere2.location.x) / 2,
(sphere1.location.y + sphere2.location.y) / 2,
(sphere1.location.z + sphere2.location.z) / 2)
# Calculate distance from midpoint to origin
distance_to_origin = math.sqrt(midpoint[0]**2 + midpoint[1]**2 + midpoint[2]**2)
# Create new sphere at midpoint of initial sphere positions
bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, location=midpoint)
new_sphere = bpy.context.active_object
# Create new torus with calculated major radius at origin
bpy.ops.mesh.primitive_torus_add(align='WORLD', major_radius=distance_to_origin, minor_radius=0.01, location=(0, 0, 0))
new_torus = bpy.context.active_object
# Link new sphere to new torus
new_sphere.parent = new_torus
# Set the animation
goal_frame = animation_duration * frame_rate
for frame in range(1, goal_frame + 1):
bpy.context.scene.frame_set(frame)
angle = 2 * math.pi * (frame / (animation_duration * frame_rate))
if clockwise:
angle = -angle
# Rotate torus 1 and 2
torus1.rotation_euler.z = angle
torus1.keyframe_insert(data_path="rotation_euler", frame=frame)
torus2.rotation_euler.z = angle
torus2.keyframe_insert(data_path="rotation_euler", frame=frame)
# Rotate spheres
sphere1.rotation_euler.z = angle
sphere1.keyframe_insert(data_path="rotation_euler", frame=frame)
sphere2.rotation_euler.z = angle
sphere2.keyframe_insert(data_path="rotation_euler", frame=frame)
# Rotate new torus and sphere
new_torus.rotation_euler.z = angle
new_torus.keyframe_insert(data_path="rotation_euler", frame=frame)
new_sphere.rotation_euler.z = angle
new_sphere.keyframe_insert(data_path="rotation_euler", frame=frame)
# Set end frame
bpy.context.scene.frame_end = goal_frame
基本系 配布 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
以下 ChatGPT との対話 修正記録 と メモ・ノート
ああああああああああああああああああああああああああああああああああああああああああああ