import bpy
import math
# 1つ目の球体を作成する
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.5, enter_editmode=False, location=(0, 0, 0))
obj1 = bpy.context.active_object
# 1つ目の球体にマテリアルを設定する
mat1 = bpy.data.materials.new(name="SphereMat1")
mat1.use_nodes = True
nodes = mat1.node_tree.nodes
principled_bsdf = nodes.get("Principled BSDF")
principled_bsdf.inputs[0].default_value = (1, 0, 0, 1)
principled_bsdf.inputs[7].default_value = 0.5
obj1.data.materials.append(mat1)
# 1つ目の球体を移動する
frames = 20 * bpy.context.scene.render.fps
for i in range(frames):
if i < frames/2:
obj1.location = ((60 / frames) * i - 30, 0, 0)
else:
obj1.location = (0, (-60 / frames) * (i - frames/2) - 30, 0)
obj1.keyframe_insert(data_path="location", frame=i)
bbb