Bmesh: Where did the UV coords go?

I’m trying to update an script I wrote, but I can’t find how to set the UV coordinates. Help… please?

here is the first vertice of the first face.
bpy.context.object.data.uv_loo_layer[0].data[0].uv

So that is the equivalent of the old style uv1-4?

Meaning…


bpy.context.object.data.uv_loo_layer[0].data[0].uv #(used to be uv1)
bpy.context.object.data.uv_loo_layer[0].data[1].uv #(used to be uv2)
bpy.context.object.data.uv_loo_layer[0].data[2].uv #(used to be uv3)
bpy.context.object.data.uv_loo_layer[0].data[3].uv #(used to be uv4)

So can there be a bpy.context.object.data.uv_loo_layer[0].data[4].uv or higher index with bMesh?

Same problem here with vertexcolors.

Thanks, that worked, but it also exposed the extent of the damage that has been done to my script. Like correctly adding faces. I was hoping to fix it before the release, but it doesn’t look like that’s going to happen. :frowning:

Yeah, that too. Sigh.

Here is an excerpt from a custom obj importer that I wrote for MakeHuman. In all buttons, I start by checking if the Blender version is prior or later than the official 2.62 release:

def checkBMeshAware():
    global BMeshAware
    print("Blender r%s" % bpy.app.build_revision)
    BMeshAware = (int(bpy.app.build_revision) > 44136)    

In the obj importer I collect texture verts and faces:

    if texverts:
        if BMeshAware:
            addUvLayerBMesh(obname, me, texverts, texfaces)
        else:
            addUvLayerNoBMesh(obname, me, texverts, texfaces)

Here are the two functions to add UV layers.

def addUvLayerBMesh(obname, me, texverts, texfaces):            
    uvtex = me.uv_textures.new(name=obname)
    uvloop = me.uv_loop_layers[-1]
    data = uvloop.data
    n = 0
    for tf in texfaces:
        data[n].uv = texverts[tf[0]]
        n += 1
        data[n].uv = texverts[tf[1]]
        n += 1
        data[n].uv = texverts[tf[2]]
        n += 1
        if len(tf) == 4:
            data[n].uv = texverts[tf[3]]
            n += 1
    return

def addUvLayerNoBMesh(obname, me, texverts, texfaces):            
        uvtex = me.uv_textures.new(name=obname)
        data = uvtex.data
        for n in range(len(texfaces)):
            tf = texfaces[n]
            data[n].uv1 = texverts[tf[0]]
            data[n].uv2 = texverts[tf[1]]
            data[n].uv3 = texverts[tf[2]]
            if len(tf) == 4:
                data[n].uv4 = texverts[tf[3]]