I'm trying to get the coordinates for the selected UV vertices with this script:
import bpy
mesh = bpy.context.object.data
uv = mesh.uv_layers.active.data
print(uv[0].uv)
But unfortunately the coordinates printed in the console are always the same regardless of what vertices I select.
Thanks in advance.
here is the code to get the coordinates for the selected vertices in the UV/Image editor :
import bpy
import bmesh
def main(context):
obj = context.active_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
uv_layer = bm.loops.layers.uv.verify()
bm.faces.layers.tex.verify()
for f in bm.faces:
for l in f.loops:
luv = l[uv_layer]
if luv.select:
#print the coordinates
print(luv.uv)
bmesh.update_edit_mesh(me)