I have a solution but it is very long in python. Easy to reproduce in cpp 
but I would like as much as possible try to make a quick trick in python ...


---------------------------------------------------------------------------------------------------------------------------------------

#    Get All UVs
u_values = OpenMaya.MFloatArray()
v_values = OpenMaya.MFloatArray()
mfn_mesh.getUVs(u_values, v_values, "SKIN")

#    Sort UVs left / right
r_list = {}
l_list = {}

for idx, (u, v) in enumerate(zip(u_values, v_values)):

    if u < 0.5:
        r_list[str(idx)] = [u, v]
    if u > 0.5:
        l_list[str(idx)] = [u, v]

#    Get UVs sym map
sym_map = {}
for rk, rv in r_list.items():

    sym_uv = pmc.dt.Vector(1 - rv[0], rv[1], 0)

    tmp_length = None
    for lk, lv in  l_list.items():

        l_uv = pmc.dt.Vector(lv[0], lv[1], 0)
        distance = sym_uv.distanceTo(sym_uv)

        if tmp_length is None or distance < tmp_length:
            tmp_length = distance
            sym_map[rk] = lk
            del l_list[lk]

#    R vertices
r_vertices = []
for idx in sym_map.keys():
    uv_name = mesh_node.name() + ".map[" + str(idx) + "]"
    v = pmc.polyListComponentConversion(uv_name, fromUV=True, toVertex=True)
    r_vertices.extend(v)

pmc.select(vertices)

#    L vertices
l_vertices = []
for idx in sym_map.values():
    uv_name = mesh_node.name() + ".map[" + str(idx) + "]"
    v = pmc.polyListComponentConversion(uv_name, fromUV=True, toVertex=True)
    l_vertices.extend(v)

pmc.select(r_vertices)
pmc.select(l_vertices)

---------------------------------------------------------------------------------------------------------------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/a56c8ac2-4194-4b1a-8ed4-2883b0da71be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to