Is 2.73 going to break all exporting add-ons ?

I saw this:

http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.73/Addons

and I wonder if that change will break exporting add-ons. Any ideas? Thanks.

It will break some scripts, especially since you can’t put it into the code without an extra test yet.


# use before accessing bm.verts[] with blender 2.73
if hasattr(bm.verts, "ensure_lookup_table"): 
    bm.verts.ensure_lookup_table()

But many useful addons don’t use bmesh module directly so the extent of change will be hard to know.

can you elaborate a little here !

wills this be necessary for any Bmesh script ?
like I did like 100’s of primitive scripts
will I have to modify all these scripts?

is this new feature available in latest SVN on buildbot ?
or only in next 2.73

thanks for any feedback
happy bl

To answer the OP, no.

Try the addon with a recent buildbot build to see if it needs updating.

Note that this was added after looking at why some scripts became very slow, and this was one of the causes. - it wasn’t done on a whim.

This looks like pretty bad design to me. You already have a check:

if ((self->bm->elem_table_dirty & bm_iter_itype_htype_map[self->itype]) == 0)

Why not just update the table lazily then instead of spitting out an error? What’s the benefit in failing? If you tell me it’s “consistency”, I’m going to slap you!

Note: nothing against you IDeasman42

Sorry to say but looks like one of my big script for spirals
is broken again in latest SVN!

got this error

IndexError: BMElemSeq[index]: outdated internal index table, run ensure_lookup_t
able() first

will check other scripts

that is not fun !

and any idea how to correct this error ?

happy broken bl

Just tested current buildbot and following that change it looks like one of the useful functionality of the LoopTool Gstretch is broken too

-> default factory -> enable loop tools addon
-> select default cube -> go to Edit Mode
-> Delete default Cube -> Hold D and make a grease pencil stroke
-> click on GStretch button , error :
http://i.imgur.com/2dERnqF.jpg

In “stable” 2.72b it worked perfect !

How about reading the page motorsep linked to?

I already did and it does not cover it
I don’t use this " BMElemSeq[index] " command

but looks like other Bmesh commands are broken too
that is my question how do you correct these !

other script I tested gives me error
gear1.py", line 210, in execute
IndexError: BMElemSeq[index]: outdated internal index table, run ensure_lookup_t
able() first

for line

if vid > 0: # Add edges
–> edges.append(bm.edges.new((bm.verts[vid-1], bm.verts[vid])))
vid+= 1

&&&

I treid to add the new command vefore in the for loop
but not working as expected

bm.verts.ensure_lookup_table(); v = bm.verts[i]

if vid > 0: # Add edges
edges.append(bm.edges.new((bm.verts[vid-1], bm.verts[vid])))
vid+= 1

thanks

any examples for using this new command?

I was able to make it work like this inside a loop

bm.verts.ensure_lookup_table()
#v = bm.verts[i]

if vid > 0: # Add edges
edges.append(bm.edges.new((bm.verts[vid-1], bm.verts[vid])))
vid+= 1

this does not crash

but that is probably not the proper way!

don’t know how to use the second part v = bm.verts[i]

thanks

even the error message tells you what to do…

you shouldn’t use it in a loop if not absolutely necessary.

try this file run script
add mesh molding and select spiral archimed

it works in latest SVN
but if you remove the new command it does not work anymore

so how can this be modified the proper way to work in a for loop

test1.blend (106 KB)

thanks

F**ck, three of my much needed addons are broken ;(
Is it hard to make the changes to let them work again?

Is there an example of an addon rescript how this new operator works?!

it’s not an operator, it’s an RNA method. Just add calls to the new method to ensure that the required lookup table is generated / updated.

Example fix commit:
https://developer.blender.org/rBA8d862e9ec3971513f469f581a04038fc120e9385

Thank you codemax so much!
I will try to solve the three addons…
When i fix these three plugins i will upload them here…
Its the Filletplus, Move faces Normal and the outliner meshs script

Here is the FAN addon

import bpy
import bmesh
import mathutils
import math

bl_info = {
“name”: “Faces Along Normals”,
“description”: “Move faces along individual normals.”,
“author”: “Márcio Daniel da Rosa”,
“version”: (1, 0),
“blender”: (2, 64, 0),
“location”: “3D View (Edit Mode) > Specials menu (W key) > Move Faces Along Normals”,
“warning”: “”,
“category”: “Mesh”}

Operator to move the faces. It first calculates a new position for each vertex of the face, for all

selected faces. So, if a vertex is shared with more than one selected face, it will have more than

one calculated position. So, the final position is calculated given a list of calculated positions

for that vertex.

class MoveFacesAlongNormalsOperator(bpy.types.Operator):
‘’‘Move the faces along individual normal vectors.’’’
bl_idname = “fan.move_faces_along_normals_operator”
bl_label = “Move Faces Along Normals”
bl_options = {‘REGISTER’, ‘UNDO’}

distance = bpy.props.FloatProperty(name="Distance", subtype='DISTANCE', step=1, precision=3)
@classmethod
def poll(cls, context):
    return context.active_object is not None and context.object.mode == 'EDIT'
# Executes the translation for each selected face. If no faces are affected, then translate all faces.
def execute(self, context):
    if self.distance != 0:
        bm = bmesh.from_edit_mesh(context.object.data)
        some_face_was_affected = self.translate_faces(bm, True)
        if not some_face_was_affected:
            self.translate_faces(bm, False)
        bm.normal_update()
        context.area.tag_redraw()
    return {'FINISHED'}

# Move the faces. Input: the bmesh and a flag to define if only the selected faces must be translated,
# or all faces must be translated. Output: True if some face was translated, false if not.
def translate_faces(self, mesh, selected_faces_only):
    some_face_was_affected = False
    calculated_translations_by_vertex_index = dict()
    for face in mesh.faces:
        if face.select or not selected_faces_only:
            self.calculate_translations_for_face_verts(calculated_translations_by_vertex_index, face)
            some_face_was_affected = True
    self.translate_verts(mesh, calculated_translations_by_vertex_index)
    return some_face_was_affected

# Calculate the translation for each vertex in the face, along the face normal. Input: the dict where
# the translation vector will be stored by the vertex index and the face.
def calculate_translations_for_face_verts(self, results_dict, face):
    for vertex in face.verts:
        translation = mathutils.Vector()
        translation.x = face.normal.x * self.distance
        translation.y = face.normal.y * self.distance
        translation.z = face.normal.z * self.distance
        if vertex.index in results_dict:
            results_dict[vertex.index].append(translation)
        else:
            results_dict[vertex.index] = [translation]

# Calculates the position for each vertex and updates the coordinates. Input: the bmesh and the dictionary
# with the calculated translations for the vertices.
def translate_verts(self, mesh, translations_by_vertex_index):
    for vertex_index in translations_by_vertex_index.keys():
        vertex = mesh.verts[vertex_index]
        translations = translations_by_vertex_index[vertex_index]
        sum = self.sum_points(translations)
        cathetus = self.distance
        angle = sum.angle(translations[0])
        h = cathetus / math.cos(angle)
        sum.length = abs(h)
        vertex.co += sum

# input: list of coordinates, output: a coordinate, the sum of the input coordinates
def sum_points(self, coordinates):
    final_coordinate = mathutils.Vector((0, 0, 0))
    for co in coordinates:
        final_coordinate += co
    return final_coordinate

Draws the operator in the specials menu

def specials_menu_draw(self, context):
self.layout.operator(“fan.move_faces_along_normals_operator”)

Draws the operator in the faces menu

def faces_menu_draw(self, context):
self.layout.separator()
self.layout.operator(“fan.move_faces_along_normals_operator”)

def register():
bpy.utils.register_class(MoveFacesAlongNormalsOperator)
bpy.types.VIEW3D_MT_edit_mesh_specials.append(specials_menu_draw)
bpy.types.VIEW3D_MT_edit_mesh_faces.append(faces_menu_draw)

def unregister():
bpy.utils.unregister_class(MoveFacesAlongNormalsOperator)
bpy.types.VIEW3D_MT_edit_mesh_specials.remove(specials_menu_draw)
bpy.types.VIEW3D_MT_edit_mesh_faces.remove(faces_menu_draw)

if name == “main”:
register()

you can use now the Shrink/Fatten with face-normals when used in face-mode

Release note 2.73 http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.73/Modeling

Thank you Mkbreuer, but is it the same?!
Bytheway i found that edge fillet and the fillet addons are integrated and update by Meta-Androcto. Thank you Meta.
I contacted the author of Fan and he will update it the bnext weeks…
Puh The saga can go on :wink:

really thanks for this… … but I think is an unnecesary RNA method :stuck_out_tongue:

which new surprises in 2.73??