20230810 用 配布ファイル

 

 

 

 

 

 

 

drive.google.com

 

配布 20230810 時計回り 円周への 第一段階 投影.blend - Google ドライブ

 

 

 

 

 

 

 

import bpy

import math

 

# 初期設定

torus_major_radius = 1.0  # トーラスのメジャー半径

torus_minor_radius = 0.05  # トーラスのマイナー半径

sphere_radius = 0.07  # 球体の半径

animation_duration = 20  # アニメーションの時間(秒)

frame_rate = bpy.context.scene.render.fps

clockwise = True  # 時計回り: False, 反時計回り: True

 

# トーラスを作成

bpy.ops.mesh.primitive_torus_add(align='WORLD', major_radius=torus_major_radius, minor_radius=torus_minor_radius, location=(0, 0, 0))  # 描画開始位置

torus = bpy.context.active_object

 

# 球体を作成

bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, location=(1, 0, 0))  # 描画開始位置

sphere = bpy.context.active_object

 

# 球体をトーラスにリンク設定

sphere.parent = torus

 

# ゴール時間を設定

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

    torus.rotation_euler.z = angle

    torus.keyframe_insert(data_path="rotation_euler", frame=frame)

 

# アウトライナで全てのオブジェクトを選択解除

bpy.ops.object.select_all(action='DESELECT')

 

# endを530フレームに設定

bpy.context.scene.frame_end = 530

 
 
 
 
 
import bpy
import math
 
# 初期設定
torus_major_radius = 1.0  # トーラスのメジャー半径
torus_minor_radius = 0.05  # トーラスのマイナー半径
sphere_radius = 0.07  # 球体の半径
animation_duration = 20  # アニメーションの時間(秒)
frame_rate = bpy.context.scene.render.fps
clockwise = False  # 時計回り: False, 反時計回り: True
 
# トーラスを作成
bpy.ops.mesh.primitive_torus_add(align='WORLD', major_radius=torus_major_radius, minor_radius=torus_minor_radius, location=(0, 0, 0))  # 描画開始位置
torus = bpy.context.active_object
 
# 球体を作成
bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, location=(-1, 0, 0))  # 描画開始位置
sphere = bpy.context.active_object
 
# 球体をトーラスにリンク設定
sphere.parent = torus
 
# ゴール時間を設定
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
    torus.rotation_euler.z = angle
    torus.keyframe_insert(data_path="rotation_euler", frame=frame)
 
# アウトライナで全てのオブジェクトを選択解除
bpy.ops.object.select_all(action='DESELECT')
 
# endを530フレームに設定
bpy.context.scene.frame_end = 530
 

 

 

コピー元 ChatGPT python

 

今日の書き出し設定 項目メモ帳 2023: 20230809 完成 トーラスと 球体 リンク回転 フレーム530

 

 

 

 

 

2023na2022.blogspot.com