Skip to content

Instantly share code, notes, and snippets.

@openroomxyz
Created April 21, 2020 12:23
Show Gist options
  • Save openroomxyz/8b540bcf2e4c481b307068c605773079 to your computer and use it in GitHub Desktop.
Save openroomxyz/8b540bcf2e4c481b307068c605773079 to your computer and use it in GitHub Desktop.
Blender Python : How we can create animations in CODE? [ An example ]
import bpy
start_position = [-31, 138, 2.7]
positions = [ [0,3,2], [4, 1, 6], [3, -5, 1], [3, 10, 1], [1, 8, 1]]
def set_object_a_keyframe_for_location(name, xyz, frame_num):
ob = bpy.data.objects[name]
bpy.context.scene.frame_set(frame_num)
ob.location = xyz
ob.keyframe_insert(data_path="location", index = -1)
frame_num = 0;
for position in positions:
cal_position = [position[0] + start_position[0], position[1] + start_position[1], position[2] + start_position[2]]
set_object_a_keyframe_for_location("BENKO", cal_position, frame_num)
frame_num += 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment