# This is not a real module, it's simply an introductory text. """ The Blender Python API Reference ================================ An asterisk (*) means the module has been updated. Top Module: ----------- - L{Blender} (*) Submodules: ----------- - L{Armature} - L{Bone} - L{NLA} - L{BGL} - L{Camera} (*) - L{Curve} (*) - L{Draw} (*) - L{Effect} - L{Image} (*) - L{Ipo} - L{Lamp} - L{Lattice} - L{Library} - L{Material} - L{Mathutils} (*) - L{Metaball} - L{NMesh} (*) - L{Noise} - L{Object} (*) - L{Registry} (*) - L{Scene} (*) - L{Radio} - L{Render} - L{Sound} - L{Text} - L{Text3d} (new) - L{Texture} - L{Types} - L{Window} - L{Theme} - L{World} - L{sys} (*) Additional information: ----------------------- - L{Special features}: - scripts: registering in menus, documenting, configuring (new); - command line examples (new); - script links (*), space handler script links (new). Introduction: ============= This reference documents the Blender Python API, a growing collection of Python modules (libraries) that give access to part of the program's internal data and functions. Through scripting Blender can be extended in real-time via U{Python }, an impressive high level, multi-paradigm, open source language. Newcomers are recommended to start with the tutorial that comes with it. This opens many interesting possibilities, ranging from automating repetitive tasks to adding new functionality to the program: procedural models, importers and exporters, even complex applications and so on. Blender itself comes with some scripts, but many others can be found in the Scripts & Plugins sections and forum posts at the Blender-related sites listed below. Scripting and Blender: ====================== These are the basic ways to execute scripts in Blender: 1. They can be loaded or typed as text files in the Text Editor window, then executed with ALT+P. 2. Via command line: C{blender -P } will start Blender and execute the given script. can be a filename in the user's file system or the name of a text saved in a .blend Blender file: 'blender myfile.blend -P textname'. 3. Via command line in I{background mode}: use the '-b' flag (the order is important): C{blender -b -P }. can be any .blend file, including the default .B.blend that is in Blender's home dir L{Blender.Get}('homedir'). In this mode no window will be opened and the program will leave as soon as the script finishes execution. 4. Properly registered scripts can be selected directly from the program's menus. 5. Scriptlinks: these are also loaded or typed in the Text Editor window and can be linked to objects, materials or scenes using the Scriptlink buttons tab. Script links get executed automatically when their events (ONLOAD, REDRAW, FRAMECHANGED) are triggered. Normal scripts can create (L{Text}) and link other scripts to objects and events, see L{Object.Object.addScriptLink}, for example. 6. A script can call another script (that will run in its own context, with its own global dictionary) with the L{Blender.Run} module function. Interaction with users: ----------------------- Scripts can: - simply run and exit; - grab the main input event queue and process (or pass to Blender) selected keyboard, mouse, redraw events; - pop messages, menus and small number and text input boxes; - draw graphical user interfaces (guis) with OpenGL calls and native program buttons, which stay there accepting user input like any other Blender window until the user closes them; - make changes to the 3D View (set visible layer(s), view point, etc); - tell Blender to execute other scripts (see L{Blender.Run}()); - use external Python libraries, if available. You can read the documentation for the L{Window}, L{Draw} and L{BGL} modules for more information and also check Python's site for external modules that might be useful to you. Note though that any imported module will become a requirement of your script, since Blender itself does not bundle external modules. Command line mode: ------------------ Python was embedded in Blender, so to access bpython modules you need to run scripts from the program itself: you can't import the Blender module into an external Python interpreter. On the other hand, for many tasks it's possible to control Blender via some automated process using scripts. Interested readers should learn about features like "OnLoad" script links, the "-b " (background mode) and "-P