0
$\begingroup$

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.

enter image description here

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:
    if loop[uv_layer].select and loop.link_loop_next[uv_layer].select:
        loop_seq.append(loop.link_loop_next)
        loop = loop.link_loop_next
    else:
        break

Is there any mistake above codes?

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – dr. Sybren Dec 5 '17 at 14:26
  • $\begingroup$ sorry, i forgot to paste code. i edited $\endgroup$ – nutti Dec 5 '17 at 14:31
  • 1
    $\begingroup$ 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. $\endgroup$ – dr. Sybren Dec 5 '17 at 15:06
  • $\begingroup$ Thanks. i think we don't have any solution to realize that without your solution. $\endgroup$ – nutti Dec 7 '17 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.