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...

October 06, 2012


When I started writing this blog it was to chronicle my findings, and the lack of (easily accessed) documentation at the time kept spurring me on. But times have changed and as of 2.64 the api documentation is slowly getting more love. The best documentation to my mind is now available at blender.org / api documentation . If you haven't read it inside out you should make time for it, before asking questions on forums.

If you are in the process of learning BPY, the above link should cover most of your needs. If you don't know Python well yet then I have documented my thoughts on how to improve your python knowledge. Also follow a few python oriented twitter accounts for the latest articles and videos about the language: namely @getpy, @PythonWeekly, @thePSF (the python software foundation), and my twitter @zeffii. All of these are low tweet volume accounts.

The main reason I wanted to learn python was because of blender, and the main reason i wanted to learn blender is to make cool algorithm driven animations for my music. I will be focussing on Motion Graphics from this point. The old content will still remain on the blog.

visit and bookmark blenderpython.tumblr for the next chapter of this saga.


  1. Hi!
    I am quietly following your blog because I am beginner in Python. Not much in position to give professional opinion, but I think your posts are very useful for understanding and learning Python for Blender.
    I would like to thank you for sharing your experience and findings and I am looking forward to see tutorials on Blender Python for example creating different types of GUIs.
    Best regards!

  2. You are welcome to all of it! Some of it isn't great python but I only know that now after having written a bunch of it. The only thing I can't give to people is the unspoken insight gained by probing python and blender, all the failed experiments have been equally important.

    I'm undecided about the future, but I would like to make it easier for people to chime in or ask questions (maybe not on blogspot, and also beyond blender)

  3. Hi! Can you please help me out... I am writing python script that should set vertex colors, and i am getting "precision" problem. E.g.

    >>> bpy.context.object.data.vertex_colors.active.data[0].color[0] = 0.5
    >>> bpy.context.object.data.vertex_colors.active.data[0].color[0]

    If I put this in blender console (test obj has vcol layer and is selected), instead of setting red color value of some vertex to exactly 0.5, I am getting incorrect value. I know that there is precision issue with floats, but I need at least 4-5 digits precision. If you know how to solve this please let me know. Thank you!

    1. With colours there are only 255 levels per r,g,b. Imagine drawing a scale that increases for 0.0 to 1.0 by increments of 1/255. Somewhere along the middle you get a number that is not quite .5

    2. >>> 0.49803921580314636 / ( 1.0/255.0)

      >>> (0.49803921580314636 / ( 1.0/255.0) ) * 2

      that's what's happening.

    3. if you use 256 for those calculations, the result is much cleaner.

    4. Thank you, I found that round(0.5 * 256)/255 works best for my needs :)

      I just don't know why would they perform any kind of operation (conversion) on float. Graphic cards/APIs (OpenGL) and shaders use float values, not bytes.

      I wrote script that copies active uv layer to vertex color R,G - I need it to use it as workaround since Unity supports only 2 uv channels import from FBX. That is why precision is of importance :). Anyway, thank you for helping out!

    5. No problem ds44.

      I agree it doesn't seem very logical, and without looking at the code involved in the Color class you'll never know. But my suspicion is that the colour class has a discreet range that steps in 1/256 jumps between 0.0 and 1.0. upon setting input values for r g and b you will get the closest value. The closest in that stepped range to 0.5 is would appear to be .4980~. Only a very select few people can even see the difference between #1290AE and #1390AE side-by-side.

      For code like you are using, yeah..you'll get a bit over overhead.


    6. step_value = 1.0/255.0
      for i in range(255): print(step_value*i)

      you'll notice 0.4980392156862745 in the middle.


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