Advertisement

You're blocking ads, which pay for BlenderNation. Read about other ways to support us.

Blender 2.5 Python Code Snippets

21

ThomasL has published a useful 74-page Python 'cookbook' for Blender 2.5.

ThomasL writes:

With the arrival of the Blender 2.5x versions of Blender, Python scripting is taken to a new level. Whereas the Python API up to Blender 2.49 was quite incomplete and ad hoc, the API in Blender 2.5x promises to allow for python access to all Blender features, in a complete and systematic way.

However, the learning curve for this amazing tool can be quite steep. The purpose of these notes is to simplify the learning process, by providing example scripts that illustrate various aspects of Python scripting in Blender.

The focus is on data creation and manipulation. Here is a list of the topics covered:

  • Meshes.
  • Vertex groups and shapekeys.
  • Armatures.
  • Rigged mesh.
  • Applying an array modifier.
  • Three ways to construct objects.
  • Materials.
  • Textures.
  • Multiple materials on a single mesh.
  • UV texture.
  • Object actions.
  • Posebone actions.
  • Parenting.
  • Drivers.
  • Particles.
  • Hair.
  • Editable hair.
  • Texts.
  • Lattices.
  • Curves.
  • Paths.
  • Camera and lights.
  • Layers.
  • Groups.
  • Worlds.
  • Render settings and viewports.
  • Batch run.

Some of the things that you will not find in these notes, at least not in the present revision:

  • User interfaces, button layouts, etc.
  • Macros, acting on what is currently selected.
  • Nodes, for materials, compositing, etc.
  • Game engine stuff.
  • Brushes and sculpting.
  • Advanced rendering, video compositing, ...

Links

About the Author

Avatar image for Bart Veldhuizen
Bart Veldhuizen

I have a LONG history with Blender - I wrote some of the earliest Blender tutorials, worked for Not a Number and helped run the crowdfunding campaign that open sourced Blender (the first one on the internet!). I founded BlenderNation in 2006 and have been editing it every single day since then ;-) I also run the Blender Artists forum and I'm Head of Community at Sketchfab.

21 Comments

  1. First post!

    Downloaded, and I'll take a look at it! I wanted to learn Python programming for 2.4x, but I never did. Maybe that's a good thing, since now the API is so different :)

  2. I always find examining code examples a much better way to learn a new language/API than trying to follow convoluted tutorials.

    Thanks very much for these.

  3. Now this sound like a new opportunity for me to learn Python Script with 2.53
    Thank you for your this stunning piece of Work.

  4. Great! I spent a few hours with 2.53 recently, and it's an incredible piece of software. Good examples and documentation is a plus! Thanks.

  5. Awesome! Thanks! Keep em coming, nothing schools you more than trying out and editting an example! I can really have some fun with these! :D

  6. Blending BriGuy on

    I liked this little glitch in the readme file:

    "Some of the things that you will not find in these notes, at least not in the
    present revision. This is not to say that these are important topics."

    Just slightly amusing to me somehow.

  7. Hey, thanks for taking the time to do this. Very nice of you.
    I appreciate this as I'm wanting to learn more about Python in Blender.

    Cheers.

  8. Thomas Larsson on

    Update: The examples in the original document from August do not work anymore, due to changes in Blender's python API. A second edition, updated for Blender 2.54 and with many new examples, can be downloaded from

    http://rapidshare.com/files/425538067/Code_snippets_updated_for_Blender_254_2010_10_17.zip

    Major changes:
    * The scripts work with Blender 2.54. More precisely, they have been tested with Blender 2.54.0 rev 32510, compiled from svn, on Ubuntu 10.04 64 bit.
    * User interfaces (panels, buttons, properties, menus, polling).
    * Simulations (cloth, softbodies, particle fire, smoke, rigid bodies, fluids).

    Since the API is now supposed to have stabilized, there is a fair chance that most scripts will continue to work for the foreseeable future.

  9. I learned quite a lot by reading your document.

    I have a question though: how would you make a reflecting material? I'm pretty sure it has something to do with MaterialRaytraceMirror, but I can't get it to work.

    Any ideas?

Leave A Reply

To add a profile picture to your message, register your email address with Gravatar.com. To protect your email address, create an account on BlenderNation and log in when posting a message.

Advertisement

×