Is 2.73 going to break all exporting add-ons ?

for verts and faces update it would be nice if someone could explain the logic on how to use these

bm.verts.ensure_lookup_table()
bm.faces.ensure_lookup_table()

in the thread
https://developer.blender.org/rBA8d862e9ec3971513f469f581a04038fc120e9385

or using other examples

happy bl

what more do you need? It’s pretty straight-forward, and the commit message which introduces these methods explains it quite well.

in the given link the new command is given before adding new vert
bm.verts.ensure_lookup_table()
vs = [bm.verts[j] for j in newf]

in scripts that I modified I added new command after adding new vert



   verts.append(bm.verts.new((XC,YC,ZC)))   # Add vertices
   if hasattr(bm.verts, "ensure_lookup_table"):
    bm.verts.ensure_lookup_table()
 
   if vid > 0:          # Add edges
    edges.append(bm.edges.new((bm.verts[vid-1], bm.verts[vid])))
    if hasattr(bm.edges, "ensure_lookup_table"):
     bm.edges.ensure_lookup_table()
   vid+= 1


so that is confusing !

and it looks like if you are using verts to make face you need to use the new command for verts and faces!

does it means that you also have to check verts before adding new edges ?

what does these new commands do ?
is it like a sort each time you add a new vert ?

happy bl

[QUOTE=RickyBlender;2793124]for verts and faces update it would be nice if someone could explain the logic on how to use these

bm.verts.ensure_lookup_table() see lign 91
bm.faces.ensure_lookup_table() see lign 95

hi Ricky

you can use this “add_box” template, and put it in your script > template.py
it works fine with blender 2.73

happy blending
diouke

operator_mesh_add.zip (1.21 KB)

#############
import bpy
import bmesh

def add_box(width, height, depth):
“”"
This function takes inputs and returns vertex and face arrays.
no actual mesh data creation is done here.
“”"

verts = [(+1.0, +1.0, -1.0),
         (+1.0, -1.0, -1.0),
         (-1.0, -1.0, -1.0),
         (-1.0, +1.0, -1.0),
         (+1.0, +1.0, +1.0),
         (+1.0, -1.0, +1.0),
         (-1.0, -1.0, +1.0),
         (-1.0, +1.0, +1.0),
         ]


faces = [(0, 1, 2, 3),
         (4, 7, 6, 5),
         (0, 4, 5, 1),
         (1, 5, 6, 2),
         (2, 6, 7, 3),
         (4, 0, 3, 7),
        ]


# apply size
for i, v in enumerate(verts):
    verts[i] = v[0] * width, v[1] * depth, v[2] * height


return verts, faces

from bpy.props import FloatProperty, BoolProperty, FloatVectorProperty

class AddBox(bpy.types.Operator):
“”“Add a simple box mesh”""
bl_idname = “mesh.primitive_box_add”
bl_label = “Add Box”
bl_options = {‘REGISTER’, ‘UNDO’}

width = FloatProperty(
        name="Width",
        description="Box Width",
        min=0.01, max=100.0,
        default=1.0,
        )
height = FloatProperty(
        name="Height",
        description="Box Height",
        min=0.01, max=100.0,
        default=1.0,
        )
depth = FloatProperty(
        name="Depth",
        description="Box Depth",
        min=0.01, max=100.0,
        default=1.0,
        )


# generic transform props
view_align = BoolProperty(
        name="Align to View",
        default=False,
        )
location = FloatVectorProperty(
        name="Location",
        subtype='TRANSLATION',
        )
rotation = FloatVectorProperty(
        name="Rotation",
        subtype='EULER',
        )


def execute(self, context):


    verts_loc, faces = add_box(self.width,
                               self.height,
                               self.depth,
                               )


    mesh = bpy.data.meshes.new("Box")


    bm = bmesh.new()


    for v_co in verts_loc:
        bm.verts.new(v_co)
        bm.verts.ensure_lookup_table()
        
    for f_idx in faces:
        bm.faces.new([bm.verts[i] for i in f_idx])
        bm.faces.ensure_lookup_table()
    bm.to_mesh(mesh)
    mesh.update()


    # add the mesh as an object into the scene with this utility module
    from bpy_extras import object_utils
    object_utils.object_data_add(context, mesh, operator=self)


    return {'FINISHED'}

def menu_func(self, context):
self.layout.operator(AddBox.bl_idname, icon=‘MESH_CUBE’)

def register():
bpy.utils.register_class(AddBox)
bpy.types.INFO_MT_mesh_add.append(menu_func)

def unregister():
bpy.utils.unregister_class(AddBox)
bpy.types.INFO_MT_mesh_add.remove(menu_func)

if name == “main”:
register()

# test call
bpy.ops.mesh.primitive_box_add()

################

thanks for this new example
but still confusing here

in that script the command is given after adding verts

but in the last example it was added before !

thanks

No isn´t the same! I have tested!
I have integrated into the last extended version of surface constraint:
http://www.blenderartists.org/forum/showthread.php?350794-Addon-Surface-Constraint-Tools&p=2796716&viewfull=1#post2796716

@mkbreuer

sorry do not use your script which looks amazing kit of tools!

but do you have simple example for this to clarify may be or what it is supposes to do and when!

just want to better understand how and when to use this!

thanks

Dear tungee, use a coder paragraph, not a text paragraph to send code, please!
Because you lost indentations!