0% found this document useful (0 votes)
4 views

lecture 4-blender-python

The document provides a tutorial on animating transitions using keyframes in Python with Blender. It includes code snippets for creating shapes, setting object properties, and inserting keyframes for animation. The tutorial emphasizes the use of the Blender Python API and demonstrates how to manipulate object locations and rotations over time.

Uploaded by

ma5853505
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

lecture 4-blender-python

The document provides a tutorial on animating transitions using keyframes in Python with Blender. It includes code snippets for creating shapes, setting object properties, and inserting keyframes for animation. The tutorial emphasizes the use of the Blender Python API and demonstrates how to manipulate object locations and rotations over time.

Uploaded by

ma5853505
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Animating transoption using keyframes

in python

Lecture Link

https://alexuuni-
my.sharepoint.com/: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

bpy.ops.mesh.primitive_cube_add()

#create object name

Obj1 = bpy.context.active_object

# Calling an operator - cylinder

bpy.ops.mesh.primitive_cylinder_add()

#create object name


Obj2 = bpy.context.active_object

# create object location

Obj1.location = (5.0, 5.0, 5.0)


#or
Obj1.location[0]=5 # x-axis
Obj1.location[1]=5 # y-axis
Obj1.location[2]=5 # z-axis

# Scale object

Obj1.scale[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)


Obj1.location = (-5.0, 5.0, 5.0)
Obj1.keyframe_insert(data_path = "location", frame = 20.0)
Obj1.location = (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)
Obj2.location.z+=3

You might also like