Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

January 29, 2012

blender 2.6 scripts

Most of the inner workings of a blender script written for 2.5 will closely resemble those for 2.6x. Some 2.5 scripts will require modifications. Please find the API changes i've encountered so far, in this post : here. I welcome heads up with corresponding error messages :).

Blender 2.6 release is an exciting one. The new boolean operations (using CARVE library) are a massive leap forward. You really have to see the result to understand how cool that is. Having Cycles in Trunk is also intensely cool. I'm still chuffed to see this blogspot on 7th place out of 17m google results for "blender python". My traffic breaks down to repeated searches for the same things, which might warrant a direct tutorial rather than snippets.

import antigravity
# just do it.


  1. How does one use the existing Python API documentation to locate the method that returns a material given its name, ie: "Material.001", etc.?

    Note: This is not so much a request for the name of the method as a request for meta-information -- information on how to obtain that information.

    Normally, I'd use the console to see what Python calls are being generated as I do manual operations involving materials, but for some reason the most it will show is:


    1. I would start here.


      In the console you can query the methods available to the active_object object, using

      >>> active_object = bpy.context.active_object
      >>> dir(active_object)
      ... will print out a list of all available methods.

      you narrow it down by:
      >>> dir(active_object.data)
      ... will print out a list of all available methods.
      ... you'll see materials in this list.

      >>> active_object.data.materials[0]
      ... bpy.data.materials["Material"]

  2. Thanks! That was very helpful. I'm still struggling with the lagging UI documentation but I suppose the release notes should help, and I haven't tried that.

    1. I appreciate that to start with a new API there is a lot to cover. Perhaps you can be specific about what exactly you think the current documentation is failing at.

      Using dir() is a fantastic way to trawl through bpy. The reporting console does not give information about every user action, in this case there are .py related to all views and panels inside the /scripts/ui/ folder located in Blender 2.x.

    2. Once I respecify an output file/format, after having rendered an animation, how can I just write out the video file without re-rendering the animation? Or to be consistent: How does one find out such a thing?

      My current problem with the documentation has to do with outputting a video file once it has been rendered with Render->Render Animation. It went through all of the work and I watched each frame materialize as it was rendered. It rendered all 100 frames just fine and that would have been that if I hadn't run out of space in /tmp. I had a 0 length file there but I still had the rendered animation which I verified by clicking the play button and watching the schematic "camera view" show the action (not fully rendered but at full speed including smoke particles etc so I know it was all precomputed). So I looked around at the documentation for video output and found nothing helpful in this regard.

    3. Consider the benefits of rendering animations as a sequence of .png(/.whatever file formet), it is not uncommon to do so. Blender can in turn import a sequence of images (thousands..) and write them to an animation. If something happens during a render you continue rendering at a later stage from exactly the frame desired.

      What blender lacks in documentation, people at blendercookie.com and blenderartists.org and all over vimeo/youtube make up for with home grown tutorials. All those sites have good searchability.


Please use Blender.StackExchange.com for python scripting questions unrelated to this post.