I’m trying to figure out how to read the UV texture coordinates from a mesh. I figured out you can find them in:
my_mesh.uv_textures.active.data
Each item in data is of some type that contains uv{1|2|3|4} [ {0|1} ]
So I guesses those values represent the texture coords for a face. Now I need to know which coords represent what face. I didn’t find an ‘obvious’ member that could point me to the belonging face. I thought that it may be the index, that the coords from my_mesh.uv_textures.active.data[x] belong to the face my_mesh.faces[x], but I tested the length both collections, and they don’t seem to be equal, not even relative. Anyway, maybe it is still true, but I just need confirmation.
That seems to work for me. You might like to look at ‘/scripts/templates/uv_operator.py’ (though I think there are more efficient and idiomatic ways of doing the iteration).
Hmmm, now that I exported the coordinates, I need to export the texture map itself where to coordinates point to. I also want to export the diffuse map and the specular map. I thought I could find them in:
bpy.context.active_object.active_material.diffuse_ramp
bpy.context.active_object.active_material.specular_ramp
bpy.context.active_object.active_material.active_texture.color_ramp
But they all seem to be of NoneType and not accessible.
Can someone help me finding these texture data?
Ramps are not maps. I think you have to work through the ‘texture_slots’ to find the result you want. If you don’t want to do all that processing yourself, you may get some joy from bpy.ops.object.bake_image in conjunction with the bake settings in bpy.types.RenderSettings.