Introduction to Scripting with Python in Blender

In this Blender 2.5 video tutorial, I will be giving a full introduction to scripting in Blender Python.

In the first half of the video I will give an overview of the basics of Python in general, such as variables, for-loops, if-statements and functions.

The second half will focus on Blender’s bpy-module and it’s API, as well as performing some basic tasks like changing a Material’s Shader-type.

Leave Comment

Discussion

63 Responses to “Introduction to Scripting with Python in Blender”
  1. Posts: 1
    rozzmatron says:

    hi can anyone help me, i want to basically get a python script to do the same thing that an action actuator would ie play an animation when a keyboard event is pressed

  2. Posts: 1
    Dave says:

    Very Nice tutorial !!

    You make a mistake at 25:00.

    You write : for key in GSOC:
    if(GSOC[key]) is “Camera Tracker”:
    print(person)

    But you have to print the key so : print(key)

    dave

  3. Posts: 25
    Ben Morgan says:

    Thank you so much patrick! This was a very good tutorial. I have some experience in Java and I have found Python to be relatively straightforward. Maybe it’s like learning a language–once you learn one, all you have to do is translate :)

  4. Posts: 1

    A very good tutorial :)
    I was playing with lists, tuples and dictionaries and it turns out there is quite a difference between “is” and “==”

    planets = (‘Mercury’, ‘Venus’, ‘Earth’)
    planetList = [planets[0], planets[1],planets[2]]
    planetDict = {planets[0] : planetList[0], planets[1] : planetList[1], planets[2] : planetList[2]}

    print()

    for planet in planetDict:
    if planetDict[planet] is ‘Mercury':
    print(planet)

    In this example I went a little crazy :) I use a dictionary that references a tuple and a list that references that same tuple again.

    If you run this script it only results with a new blank line.

    If you change “‘Mercury'” to “planetList[0]” it prints the correct value (‘Mercury’)
    But if you change “is” to “==” both “‘Mercury'” and “planetList[0]” work.

    If I understand it correctly the “is” operator checks if the elements are the same, while “==” compares if their values are the same.

  5. Posts: 2
    vladson says:

    A very useful tutorials.

    But I don’t understand if one know basics how can he create something big-and-important?

    • Posts: 4011

      Hey vladson,

      It’s all a matter of experience and taking things one step at a time. I believe it’s best to not focus on creating something ‘big-and-important” but instead to try and solve one small problem at a time. Start small and slowly work up from there.

      For some more small steps check out our other python tutorials: http://cgcookie.com/blender/category/tutorials/scripting/

Leave a Comment

You must be logged in to post a comment.