# How to obtain sequence of selected UV in Python?

Sorry for continuous post from below post.
This question is related to it.

How to obtain selected UV pairs on same edge in Python?

I want to obtain sequence of selected UV in Python.
But I did not come up with the implementation.

I show you my trial code.
This code DOES NOT work correctly. (only 2 loops can be obtained)

obj = context.active_object
bm = bmesh.from_edit_mesh(obj.data)
uv_layer = bm.loops.layers.uv.verify()
sel_faces = [f for f in bm.faces if f.select]

for f in sel_faces:
for l in f.loops:
if l[uv_layer].select:
first_loop = l
break

loop_seq = [first_loop]
loop = first_loop
while True:

• The code is incomplete (first_loop is undefined), so it's unclear where it comes from, and thus we can't fully understand your code. – dr. Sybren Dec 5 '17 at 14:26
• The code won't work because it is looping over faces, and then over the edges of that face. As a result, sequential loops won't be seen in a sequential manner. link_loop_next always points to the next loop of the same face. I would construct a set of (vertex1, vertex2) tuples of selected UV loops, and then parse those to obtain sequences of (vertex1, vertex2), (vertex2, vertex3), … tuples. – dr. Sybren Dec 5 '17 at 15:06