Update 2011.06.26:
Updated and tested with B2.58:
http://hotfile.com/dl/122285414/86dd604/Code_snippets_updated_for_Blender_258_2011_06_26.zip.html
Update 2011.05.07
ValterVB has ported my python cookbook to the wiki format. It is now available at
http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets
I wish to thank Valter for his work.
The pdf version has also been modified. There is no reason to download the new file if you have the old one, because the only difference is that the license statement in the text has been removed. The code snippets are now licensed under Creative Commons, to comply with the wiki requirements. The new pdf file can be found at
http://hotfile.com/dl/116601588/a03f0bb/Code_snippets_updated_for_Blender_257_2011_05_03.zip.html
Update 2011.04.14. A new version of the code snippets can be downloaded fromhttp://hotfile.com/dl/114370840/3347eb7/Code_snippets_updated_for_Blender_257_2011_04_14.zip.html
All scripts have been updated for Blender 2.57 and work, or at least do not generate any errors, with the official release. New examples have been added in the following areas.
- Custom properties.
- Interface and operators.
- Blender add-ons.
- Multi-file packages
- Nodes
Update 2010.10.17: 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://www.makehuman.org/download/Code_snippets_updated_for_Blender_254_2010_10_17.zip
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.
Original post:
I have written a little text with small scripts examples in Blender 2.5x. The examples are not really usable (hence the word snippets), but illustrate how to access various features. All program do run in Blender 2.53.1 (at least on my computer), and there is a batch file which runs all examples in the text.
The pdf and python files can be downloaded from http://rapidshare.com/files/411523215/Code_snippets_Intro_to_scripting_in_Blender_25x_2010_08_07.zip.html .
(Update 2010.08.07. New download. Added missing image file and corrected some spelling errors.)
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, …