Pulling UV Texture Name From Object

I’m writing a script for a custom exporter for a game I’m working on. This script will store information for all the objects in a scene. How can I get the name of the UV texture that is assigned to an object?

That is depends on what you are referring to when you say “the UV texture that is assigned to an object.”

Off the top of my head, there are at least two ways to make an object textured in Blender. The ‘real’ way to texture an object in Blender is to create a material and configure the texture data as part of the Mat. Blender Internal materials support having multiple textures applied to them. In terms of a game setting you might want a diffuse map for the color of your model and a normal map to get extra details into them.

The other way to texture a character is when you have “Texture Solid” enabled in the display port. In this case, each face in your Mesh is assigned an “active image” which is used.

Depending on which way you have done this, then the data lives in a different spot.

obj = bpy.data.objects['Cube']     #gets the object
uv_name = obj.data.uv_textures[0].name    #gets the name of the object's first UV texture

thanks cmomoney, that got me close. What i was looking for was the name of the texture file, and i got it from bpy.data.objects[0].data.uv_textures[0].data[0].image.name

Oh, so you wanted the name of the image assigned to the UV texture. Oh well, glad you found it. :slight_smile: