7

I downloaded Blur Weights addon, since it was made for blender 2.63 it is giving an error in blender 2.74 when trying to use it.

enter image description here

enter image description here

Why does this error happens and how can it be fixed to make outdated addons to work with newer versions of blender?

Addon link

Denis
  • 13,059
  • 7
  • 60
  • 81
  • 1
    https://github.com/assumptionsoup/Blur-Weights/issues/1 someone has already offered a fix in the addon's issue tracker, you can apply the fix locally. or try the fork: https://github.com/zeffii/Blur-Weights – zeffii May 31 '15 at 05:42

1 Answers1

14

This was added to speed up scripts. The Blender 2.73 release notes mention it and reference the commit that introduced it (in the Python API section)

A backwards compatible solution is the following addition before any code that accesses bm.verts / bm.edges / bm.faces indices explicitly. For clarity, that means if an addon has any code like this:

bm.verts[i]
bm.edges[i]
bm.faces[i]

Then preceding it must be a call to ensure_lookup_table. Often you'll only need to do one such call, and you'll want to stick it outside of any tight loops if possible.

if hasattr(bm.verts, "ensure_lookup_table"): 
    bm.verts.ensure_lookup_table()
    # only if you need to:
    # bm.edges.ensure_lookup_table()   
    # bm.faces.ensure_lookup_table()

If you add new verts / edges / faces to the bm, and then subsequently do an indexed lookup you might find that you need to call ensure_lookup_table again.

zeffii
  • 39,634
  • 9
  • 103
  • 186