When working with a BMesh object in the Blender Python API, we can get UV points from the vertices of the object itself, just like with the base object.
Add a cube to the scene (if you havn’t one by default). The cube already has an automatically generated UV map. Switch to edit mode and select one polygon.
Now let’s get the UV coordinates for the selected polygon using the BMesh object.
Create a BMesh object and copy the geometry of the currently active object (the cube) to it. Ensure vertices indices.
|
1 2 |
bm = bmesh.from_edit_mesh(bpy.context.object.data) bm.verts.ensure_lookup_table() |
First, let’s take the selected polygon.
|
1 2 3 |
selected_face = next((_face for _face in bm.faces if _face.select), None) # <BMFace(0x000001C6C5DB71C0), index=2, totverts=4> |
We also need a pointer to the current UV layer.
|
1 2 3 |
active_uv_layer = bm.loops.layers.uv.active # <BMLayerItem object at 0x000001C6C95CDFE0> |
Get a pointer to the meshloop of the selected polygon.
|
1 2 3 |
loop = selected_face.loops # <BMElemSeq object at 0x000001C6CA302670> |
Now, using the meshloop, we can get a combined list of vertices of the 3D object itself (in BMesh) and points on the UV map.
|
1 2 3 |
uv_points = [(_loop.vert, _loop[active_uv_layer]) for _loop in selected_face.loops] # [(<BMVert(0x000001C6B544F1A8), index=5>, <BMLoopUV object at 0x000001C6CC469FE0>), ...] |
We can get the coordinates of the points themselves using the “uv” property of the points on the UV map (BMLoopUV). Get the combined list with the vertex index on the geometry and the corresponding coordinates on the UV map for that vertex.
|
1 2 3 |
uv_points_cos = [(_uv_point[0].index, _uv_point[1].uv) for _uv_point in uv_points] # [(6, Vector((0.44891229271888733, 0.6140835285186768))), ...] |
Another useful option is to get a list of all mesh vertices, linking a vertex with its coordinates on the UV map. This call can be executed in a single line.
|
1 2 3 |
uv_p_cos = [(_loop.vert, _loop[active_uv_layer].uv) for _face in bm.faces for _loop in _face.loops] # [(<BMVert(0x000001C6B544F090), index=0>, Vector((-0.007421731948852539, 0.4097326993942261))), ...] |
The first element in the resulting list is a pointer to a vertex in 3D space in the BMesh object, and the second is a vector with its coordinates in 2D UV space.

.blend file on Patreon