Blender Scripting Lesson - 1 Hour Session
1. Introduction to Blender Scripting (10 min)
In this session, we'll cover the basics of scripting in Blender using Python. We'll look at creating objects,
manipulating them, and basic automation. Blender scripting uses the bpy module which gives us access to
Blender's features.
2. Accessing the Blender Console (5 min)
- Open Blender and switch to the Scripting workspace.
- Import the 'bpy' module using the command:
import bpy
- This allows us to interact with Blender's API.
3. Creating a Simple Object (10 min)
We'll start by creating a simple cube using the following command:
[Link].primitive_cube_add(size=2, location=(0, 0, 0))
This will add a cube of size 2 at the origin. The '[Link]' module lets us add objects.
4. Manipulating Objects (10 min)
We can move, rotate, and scale the cube using Python commands:
- To move the object:
cube = [Link]
[Link] = (1, 2, 3)
- To rotate the object:
cube.rotation_euler = (0.5, 0.5, 0)
- To scale the object:
[Link] = (2, 1, 1)
5. Edit Mode vs Object Mode (5 min)
Switching between Object Mode and Edit Mode:
[Link].mode_set(mode='EDIT')
[Link].mode_set(mode='OBJECT')
This is important when editing geometry.
6. Basic Animation (10 min)
To animate an object, we can insert keyframes:
[Link] = (0, 0, 0)
obj.keyframe_insert(data_path='location', frame=1)
[Link] = (5, 5, 0)
obj.keyframe_insert(data_path='location', frame=50)
This animates the object from frame 1 to frame 50.
7. Rendering (5 min)
Rendering the scene to an image:
[Link] = '/tmp/[Link]'
[Link](write_still=True)
This will save the rendered image to the specified path.
8. Conclusion and Q&A (5 min)
We covered basic scripting concepts in Blender such as object creation, manipulation, animation, and
rendering. Now, you can explore more advanced features on your own. Feel free to ask questions!