def execute(self, context):
    sc = context.scene
    props = sc.muv_props.texture_lock
    obj = bpy.context.active_object
    bm = bmesh.from_edit_mesh(obj.data)
    if (common.check_version(2, 73, 0) >= 0):
        bm.verts.ensure_lookup_table()
        bm.edges.ensure_lookup_table()
        bm.faces.ensure_lookup_table()
    if (not bm.loops.layers.uv):
        self.report({'WARNING'}, 'Object must have more than one UV map')
        return {'CANCELLED'}
    uv_layer = bm.loops.layers.uv.verify()
    verts = [v.index for v in bm.verts if v.select]
    verts_orig = props.verts_orig
    for (vidx, v_orig) in zip(verts, verts_orig):
        if (vidx != v_orig['vidx']):
            self.report({'ERROR'}, 'Internal Error')
            return {'CANCELLED'}
        v = bm.verts[vidx]
        link_loops = _get_link_loops(v)
        result = []
        for ll in link_loops:
            ini_geom = _get_ini_geom(ll, uv_layer, verts_orig, v_orig)
            target_uv = _get_target_uv(ll, uv_layer, verts_orig, v, ini_geom)
            result.append({'l': ll['l'], 'uv': target_uv})
        if self.connect:
            ave = Vector((0.0, 0.0))
            for r in result:
                ave = (ave + r['uv'])
            ave = (ave / len(result))
            for r in result:
                r['l'][uv_layer].uv = ave
        else:
            for r in result:
                r['l'][uv_layer].uv = r['uv']
        v_orig['moved'] = True
        bmesh.update_edit_mesh(obj.data)
    props.verts_orig = None
    return {'FINISHED'}
def execute(self, context):
    sc = context.scene
    props = sc.muv_props.texture_lock
    obj = bpy.context.active_object
    bm = bmesh.from_edit_mesh(obj.data)
    if (common.check_version(2, 73, 0) >= 0):
        bm.verts.ensure_lookup_table()
        bm.edges.ensure_lookup_table()
        bm.faces.ensure_lookup_table()
    if (not bm.loops.layers.uv):
        self.report({'WARNING'}, 'Object must have more than one UV map')
        return {'CANCELLED'}
    uv_layer = bm.loops.layers.uv.verify()
    verts = [v.index for v in bm.verts if v.select]
    verts_orig = props.verts_orig
    for (vidx, v_orig) in zip(verts, verts_orig):
        if (vidx != v_orig['vidx']):
            self.report({'ERROR'}, 'Internal Error')
            return {'CANCELLED'}
        v = bm.verts[vidx]
        link_loops = _get_link_loops(v)
        result = []
        for ll in link_loops:
            ini_geom = _get_ini_geom(ll, uv_layer, verts_orig, v_orig)
            target_uv = _get_target_uv(ll, uv_layer, verts_orig, v, ini_geom)
            result.append({'l': ll['l'], 'uv': target_uv})
        if self.connect:
            ave = Vector((0.0, 0.0))
            for r in result:
                ave = (ave + r['uv'])
            ave = (ave / len(result))
            for r in result:
                r['l'][uv_layer].uv = ave
        else:
            for r in result:
                r['l'][uv_layer].uv = r['uv']
        v_orig['moved'] = True
        bmesh.update_edit_mesh(obj.data)
    props.verts_orig = None
    return {'FINISHED'}