Blender 3D: Noob to Pro/Advanced Tutorials/Python Scripting/Introduction

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

For a general introduction to python programming, see the official python tutorial: http://docs.python.org/tutorial/index.html

[edit] Introduction

Python is used in Blender to write plugins as well as automate tasks. It is one of the easiest programming languages to learn.

[edit] Your First Python Script

Open a text editor (e.g. "Notepad" in Windows) and type this script:

import Blender #gets all blender's functions
 
a = Blender.Object.Get("Cube") #change the name of the object you want to get
a.LocX = 2 #move the object's location-x to 2.
    • Noob question: where do I save this file, and what do I do with it once i've saved it?**


[edit] Exercises

  1. Change the script so that it sets the object's location-x to 6
  2. Change the script so that it sets the object's location-y to 1