2
$\begingroup$

I'm trying to update a 3rd party addon from Blender 2.6 to 2.7, as the author won't do it. The only problem I have is here:

ActiveUV = BMesh.data.uv_textures.active
for iFace, BFace in enumerate( BMesh.data.polygons ):
    FaceUVs = []

    if ActiveUV != None:
        for UV in ActiveUV.data[iFace].uv:
            FaceUVs.append( [UV[0], UV[1]] )

And I have this error message:

'MeshTexturePoly' object has no attribute 'uv'

I've tried with:

BMesh.data.tessface_uv_textures.active

But it returns 'None'

And with:

BMesh.data.uv_layers.active

But It doesn't seem to be the right one.

$\endgroup$
1
  • $\begingroup$ What mode is your object in? len(ob.data.uv_layers.active.data) is always 0 in Edit Mode, you need to be in Object Mode to access it. For tessface_* attributes, it is required to call Mesh.calc_tessface() beforehand. $\endgroup$
    – CodeManX
    Commented Feb 4, 2015 at 12:38

1 Answer 1

2
$\begingroup$

Ok, I've found a solution, maybe not the optimum one, but it works:

for iFace, BFace in enumerate( BMesh.data.polygons ):
    FaceUVs = []

    for i in BFace.loop_indices: # <-- python Range object with the proper indices already set.
        l = BMesh.data.loops[i] # The loop entry this polygon point refers to.
        for j,ul in enumerate(BMesh.data.uv_layers):
            FaceUVs.append( [ul.data[l.index].uv[0], ul.data[l.index].uv[1]] )
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .