Scaling UVmap

Hi, all.

I’m trying to scale an existing UV map for currently selected object, the log window suggest the following:


bpy.ops.uv.select_all(action='TOGGLE')
bpy.ops.transform.resize(value=(20, 20, 20), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)

However, this works when I hover over the UV map, when I run it as a script with blender running in background, it scales the object instead.

Can it be solved?

Thanks,
Denis.

Figured it out.
For some reason, there is no built in blender function to scale UV, but this works…


def scaleUV(obj, pivot, scale):


    uvMap = obj.data.uv_layers[0]
    for d in uvMap.data:
        d.uv[0] = pivot[0] + scale[0]*(d.uv[0] - pivot[0])
        d.uv[1] = pivot[1] + scale[1]*(d.uv[1] - pivot[1])

1 Like