Animating transoption using keyframes
in python
Lecture Link
[Link]
[Link]/:v:/g/personal/nermeen_kashief_alexu_edu_eg/EbODuBy3LSJCuNx0We
g_8rYB_jFJj7vjuuX6TkP4O6IwbA?e=8WXKjy
# import API python in blender – just access path to python
import bpy
# Access math path for using rotation
from math import radians
#creat shapes
# Calling an operator – cube
[Link].primitive_cube_add()
#create object name
Obj1 = [Link].active_object
# Calling an operator - cylinder
[Link].primitive_cylinder_add()
#create object name
Obj2 = [Link].active_object
# create object location
[Link] = (5.0, 5.0, 5.0)
#or
[Link][0]=5 # x-axis
[Link][1]=5 # y-axis
[Link][2]=5 # z-axis
# Scale object
[Link][0]=2 # enlarge x-axis
# Rotated object
# assuming rotation_mode being euler by default
Obj1.rotation_euler[0]=radians(45) # need to import math for radians
# crate animation using keyframes
Obj1.keyframe_insert(data_path = "location", frame = 1.0)
[Link] = (-5.0, 5.0, 5.0)
Obj1.keyframe_insert(data_path = "location", frame = 20.0)
[Link] = (0.0, 0.0, 0.0)
Obj1.keyframe_insert(data_path = "location", frame = 40.0)
# using loop for keyframes
for I in range(1,40,4):
Obj2.keyframe_insert(data_path="location",frame =I)
[Link].z+=3