Hi - I’m writing my own exporter and I’ve reached the stage where I need to extract vertex UV texture coordinates. I’m using 2.63RC1 and bmesh but I can’t seem to find a way to get the UV’s for each vertex ?
Can someone point me in the right direction pls ?
Thanks.
Apologies… After reading some more docs I’ve found that uv’s are stored in bmesh face loops.
rebellion
(Luca Carella)
April 25, 2012, 8:01am
3
same problem, i posted a thread like your but i’ve got no answer :(…
Shagwana
(Shagwana)
April 25, 2012, 8:10am
4
you can also calc_tessface() and obtain the uv data from tessface_uv_textures!
Here is some code which should get the uv’s for a bmesh:
import bpy
import bmesh
obj = bpy.data.objects["textured bit"]
bm = bmesh.new()
bm.from_mesh( obj.data )
uv_lay = bm.loops.layers.uv.active
for face in bm.faces:
print("-face-")
for loop in face.loops:
uv = loop[uv_lay].uv
print("Loop UV: %f, %f" % (uv.x, uv.y))
rebellion
(Luca Carella)
April 26, 2012, 6:30am
6
don’t work… it said that bmesh as no attribute loops…
ThomasL
(ThomasL)
April 26, 2012, 7:14pm
7
import bpy
def printUvs(me, index):
try:
uvloop = me.uv_loop_layers[index]
except:
print("No UV loop layer")
return
n = 0
for f in me.polygons:
for vn in f.vertices:
loop = uvloop.data[n]
n += 1
print(loop.uv[0], loop.uv[1])
printUvs(bpy.context.object.data, 0)