# Get Selected UV vertices coordinates

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.

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)
• May I ask why aren't you just getting the coordinates from the UV/Image Editor? – sekce Oct 14 '17 at 23:58
• @sekce I want write a script that calculate the angle between the selected vertices(edge) and the x or y axis then align the island depending on the calculated angle, and in order to calculate the angle I need to get the coordinates of the vertices. – user47188 Oct 15 '17 at 0:42