I want to get a selected uv vertex index.

Sorry , I don’t konw english well.

I want to get a selected uv vertex index.

Why not same vertex at below?

obj.data.vertices[0] == obj.data.uv_layers[0].data[0]

I want to know obj.data.vertices[0] is where in uv_layers.

Please answer to me.

Thank you.

Attachments



They are not the same because it is possible for a single vertex to have multiple UV coordinates. Any vertex that is part of a seam will have at least 2 UV coordinates assigned to it. It is not possible to ensure that there will be a one-to-one mapping between geometry verts and UV verts.

If you know that you model has such a mapping then you can build your own lookup table by iterating the UV verts and ‘vertex_index’ property to tell which geometry vert it belongs to.

maybe this helps:

import bpy

me = bpy.context.object.data
vert_uv_map = {}
for poly in me.polygons:
    for li in poly.loop_indices:
        vi = me.loops[li].vertex_index
        uv = me.uv_layers.active.data[li].uv
        vert_uv_map.setdefault(vi, []).append((li, uv))
            
for vert_index, uvs in vert_uv_map.items():
    print("Vertex %i:
" % vert_index)
    for li, uv in uvs:
        print("	%r (loop %i)
" % (uv, li))