To make a new UV with the Python API and set coordinates to its points, we need:
First – create a new UV with the desired name:
1 |
new_uv = bpy.context.active_object.data.uv_layers.new(name='NewUV') |
Next, to specify the coordinates of its points, we need to cycle through all the “loops” of the mesh:
1 |
for loop in bpy.context.active_object.data.loops: |
and set the required coordinates through them:
1 |
new_uv.data[loop.index].uv = (x, y) |
The following code will create a new UV for the active mesh and locate its points according to the coordinates specified in the uv_co list:
1 2 3 4 5 6 7 8 |
import bpy uv_co = [(0.375, 0.0), (0.625, 0.0), (0.625, 0.25), ...] new_uv = bpy.context.active_object.data.uv_layers.new(name='NewUV') for loop in bpy.context.active_object.data.loops: new_uv.data[loop.index].uv = uv_co[loop.index] |