How to get UV Editor selected vertices in Python?


does anyone know how to get selected vertices in the UV editor using Python in 3.4? The Python API docs search is so abysmal I’ve just not been able to find the answer whatsoever :frowning:

In 3.4 you access D.meshes['Cube'].uv_layers['UVMap'].data Which is an array of the MeshUVLoop type. That contains the selection states. (MeshUVLoop(bpy_struct) — Blender Python API)

In 3.5 there’s this (new, yet to be properly documented) way, because the data is now stored in separate arrays:D.meshes['Cube'].uv_layers['UVMap'].vertex_selection which returns an array of booleans.

There’s also
also returning an array of bools.

and of course
returning an array of float2 vectors for the uvs themselves.

The older way is (for now) still supported in 3.5, but rather a lot slower because the MLoopUV structure needs to be re-created from the internal arrays, while the direct array access just directly return the data.