Meta:BSoD/2006/Proposals/Introduction to Python

提供: wiki
移動先: 案内検索

BPy Boot Camp is an introduction to basic Python scripting in Blender.

The target audience is beginning scripters who have a basic knowledge of Blender. Only minimal knowledge of Python is assumed. The beginning Python tutorial at www.python.org is used as a reference.

At the end of the course, readers will have an understanding of Blender's database structure and will be able to write simple scripts to query and manipulate Blender objects and to import and export Blender data via Python. The Blender API documentation will be introduced.

Simple example programs, suitable for cutting and pasting, will given. These can form the start of a personal library of utility routines for common scripting tasks. References will be given to the Blender Wiki documentation where appropriate.

Proposed Outline and Topics Covered:

  1. Introduction
    • Target Audience
      • Basic Blender User
      • New Scripters
    • Prerequisites
      • Blender installed.
      • A full install of Python can be done later if desired.
      • Basic Blender concepts needed:
        • Changing Window types
        • Creating, Editing and Selecting Objects
        • Loading and Saving files
    • Goals
      • Understand Blender Data Structures.
      • Create scripts for common tasks.
      • Start building a personal library of code for common tasks
    • BPy Documentation
      • Overview of BPy API documentation.
      • Details will be discussed in the following topics.
  2. The Text Editor
    • Using the Blender Text Editor:
      • New
      • Save
      • Open
      • Reload
      • Tabs vs Spaces
      • Cut & Paste
      • Comment / Uncomment
      • Indent / Un-indent
  3. First Script : Hello World!
    • We write and run our first program.
    • PROGRAM: HELLO WORLD
  4. Objects and Their Properties
    • Discuss Object Oriented nature of Python and Blender. Like everyday objects, Blender Objects have unique properties depending on their type.
    • 3D Coordinates
    • Accessing Objects
      • By Name
      • By Selection
      • PROGRAM: PRINT PROPERTIES
        • Get an Object and print its attributes
    • Setting Properties
      • Set the attribute values of an Object
      • PROGRAM: MOVE
        • Example of moving an Object. Lead-in to scriptlink discussion.
  5. Scriptlinks
    • Discussion of Scriptlinks and their uses.
    • Object Scriptlinks
      • Frame Change
      • Render
      • Redraw
    • Scene Scriptlinks
      • OnLoad
      • OnSave
      • Render
      • Redraw
      • FrameChange
      • PROGRAM: CONTINUOUS MOTION
        • Animate an Object using a FrameChange scriptlink.
  6. The Registry
    • Discussion of storing and retrieving persistent data in scripts.
    • PROGRAM: USING PERSISTENT DATA
      • Example of Registry module use.
  7. Math
    • Mention useful Python math functions. Brief introduction to MathUtils module via Vector math for Object positions.
  8. APPLICATION:FLOCKING
    • Simple Flocking. An application using what we have learned so far.
  9. PROGRAM: FOLLOW THE LEADER
    • Animating Multiple objects using Frame Change scriptlinks.
  10. Blender Database Structure
    • Discussion of Blender data structures
      • Scenes
      • Objects
      • ObData
      • Materials
    • Use of Outliner to examine data relationships
    • DIAGRAM: BLENDER OBJECT RELATIONSHIPS
      • Relationships between Scenes, Objects, ObData and Materials
  11. Creating Objects
    • Objects 101
      • We create a basic scene with Camera and Lights
      • Scene
      • Lamp
      • Camera
      • PROGRAM:NEW SCENE
        • New Scene with Camera & Lamp
    • Mesh
      • Discussion of verts, edges, faces
      • PROGRAM:NEW MESH
        • Create a Mesh
    • Curves
      • Discussion of Blender Curve types
        • NURBS
        • Bezier
        • PROGRAM: NEW CURVES
          • Create Bezier and NURB Curves.
    • IPOs
      • Discussion of IPOs
        • PROGRAM: CREATE IPO
          • Create IPOs.
  12. Materials
    • Discuss creating basic Materials and linking them to Objects
    • PROGRAM: MATERIALS
      • Create and link Material to an Object
  13. Importers and Exporters
    • Discussion of basic Python I/O in the context of moving data in and out of Blender.
    • PYTHON FILE I/O
      • Brief introduction to Python I/O.
      • PROGRAM: READ/WRITE
        • Simple text file I/O
    • PROGRAM:EXPORT
      • Write Blender objects to an external file.
    • PROGRAM: IMPORT
      • Create an object from an external file.

Deliverables:

Deliverables will consist of Wiki pages necessary to implement the above outline, including the fourteen mentioned small, commented programs and a simple diagram basic Blender data relationships.

Addition diagrams may be added as necessary to clarify points made in the text.

Qualifications:

A programmer by trade, I have been a victim of Blender since at version 1.8. I am familiar with Blender Python by virtue of working on the project and have at least moderate fluency in English.

Note: Additional details or examples can be provided as needed. Suggestions are welcomed.

--timmeh 15:26, 18 June 2006 (CEST)