You may need to get a list of coordinates of the mesh’s UV, for example, when exporting a mesh from Blender’s internal format to any external formats.
A list of the mesh UV-s can be got by accessing the “uv_layers” structure:
1 2 3 |
bpy.context.object.data.uv_layers[:] # [bpy.data.meshes['Cube'].uv_layers["UVMap"], bpy.data.meshes['Cube'].uv_layers["UVMap.001"]] |
The current (active) UV is accessed through the “active” element:
1 2 3 |
bpy.context.object.data.uv_layers.active # bpy.data.meshes['Cube'].uv_layers["UVMap"] |
Now we can get the coordinates of the points of the active mesh UV from the “data” structure with the following command:
1 2 3 |
[(data.uv.x, data.uv.y) for data in bpy.context.active_object.data.uv_layers.active.data] # [(0.375, 0.0), (0.625, 0.0), (0.625, 0.25), ... |
The “data” structure is a list of “loops” of the “MeshUVLoop” type. Each “loop” contains UV point coordinates.