Typically, a mesh’s UV map in Blender is confined to the base tile — the sector with coordinates ranging from zero to one. However, the UV map can easily be scaled so that its points extend beyond these limits. To avoid disrupting texture tiling, it is often necessary to know exactly how many tiles the map spans in each of the four directions. A simple script can be used to determine how far the map extends from the base tile.
Let’s designate the base UV tile, with coordinates (0.0, 0.0) to (1.0, 1.0), as tile number 1. Tiles along the X-axis in the positive region would then be numbered 2, 3, 4, etc., while those in the negative region would be -1, -2, etc. The same applies to the Y-axis.
We will get whether the scaled UV map extends beyond this base tile and, if so, how many sectors it covers along the X and Y axes.
The currently active object is initially in Edit Mode. To ensure accurate calculations within the script, we need to switch to Object Mode.
|
1 |
bpy.ops.object.mode_set(mode = 'OBJECT') |
Get a pointer to the object’s currently active UV map.
|
1 2 3 |
uv_layer = bpy.context.object.data.uv_layers.active # <bpy_struct, MeshUVLoopLayer("UVMap") at 0x000002D3C95A5440> |
Iterate through all the mesh polygons and compile a list of mesh loops from them.
|
1 2 3 4 |
mesh_loops = [uv_layer.data[loop_index] for _face in bpy.context.object.data.polygons \ for loop_index in _face.loop_indices] # [bpy.data.meshes['Cube'].uv_layers["UVMap"].data[0], ...] |
Now, let’s write a simple function that breaks down our list of mesh loops into X and Y coordinates and finds the minimum and maximum coordinate values for both axes.
|
1 2 3 4 5 6 7 8 |
def sector_min_max(uv_points): x, y = zip(*(p.uv for p in uv_points)) return { 'min_x': floor(min(x)), 'min_y': floor(min(y)), 'max_x': ceil(max(x)), 'max_y': ceil(max(y)) } |
Inside the function, we also round the coordinates of the points to convert the coordinate values into tile indices.
Now we can call the function and pass the list of mesh loops we obtained as an argument.
|
1 2 3 |
max_min_tiles = sector_min_max(mesh_loops) # {'min_x': -1, 'min_y': -1, 'max_x': 2, 'max_y': 2} |
The function’s output shows that, along the X-axis, the object’s UV map starts at tile index -1 and ends at tile index 2. The same by the Y-axis. Consequently, the UV map spans 3 tiles vertically and 3 tiles horizontally.

.blend file on Patreon