I am trying to figure out how to rotate UVs in mesh while Blender is in Background mode without windows, so some parts are not accessible.
Right now I am using bpy.ops.mesh.uvs_rotate()
> this works, but it is just in 90 degrees, so I am not able to set UV rotation in specific degree.
bpy.ops.object.editmode_toggle()
bpy.ops.uv.smart_project(angle_limit=66, island_margin=0, user_area_weight=0)
bpy.ops.uv.reset()
bpy.ops.mesh.uvs_rotate()
On this http://blenderartists.org/forum/showthread.php?267997-Rotate-the-uv-s-of-a-selected-object-instead-of-the-object-itself there is written, that I should use bpy.ops.transform.rotate(value=math.radians(45))
while being in bpy.context.area.type = 'IMAGE_EDITOR'
.
The problem with this is that when I run blender like
blender --python-console --background
>>> import bpy
>>> bpy.context.area.type
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'type'
>>>
It seems that object bpy.context.area.type
is not possible to change, because it does not exist. In overall our code, we try to not use this. But it case of UV I am not able to figure out how to do it without this. I know that there is a lot of problems with these context.
So how should I rotate UV without context
. Is it possible? Or is there a different way how to rotate image on separate object by specific degree?