I’m working on an addon that randomizes the UV coordinates on multiple objects. I’m having some problems when I do a rotation of the UVs, as illustrated below. On the left is the original map, in the middle is this map after a 90ï¿½ CCW rotation performed via the GUI, and on the right is this map after a 90ï¿½ CCW rotation via code.
I suppose this extra scaling happens because I’m using a non-square texture. Still, this behaviour is highly unwanted, and I would like to make it so that I get the results as you get them when you manually rotate the UVs (middle screenshot). Here’s my code:
def rotateUVsMeshOnTex(meshObject, uvTex, rZ = 0.0): bpy.ops.object.select_all(action='DESELECT') meshObject.select = True bpy.context.scene.objects.active = meshObject meshObject.data.uv_textures.active = uvTex currAreaType = bpy.context.area.type bpy.context.area.type = 'IMAGE_EDITOR' bpy.ops.object.editmode_toggle() bpy.ops.mesh.select_all(action='SELECT') bpy.ops.transform.rotate(value = rZ, axis = (0.0, 0.0, 1.0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED') bpy.ops.object.editmode_toggle() bpy.context.area.type = currAreaType