# Set active UV layer in python?

I'd like to set which UV map is selected in Properties > Object Data > UV Maps. By "selected", I'm referring to the one highlighted, not the one with the camera icon enabled.

I tried

bpy.context.object.data.uv_layers.active = bpy.context.object.data.uv_layers['AO']


But uv_layers.active remained at the previous value and there was no error message.

How can I set the active UV map from python?

• This technique also comes in handy when you are trying to prepare a mesh for texture baking, since the active UV layer seems to be important to the baking process. – Mutant Bob Aug 22 '17 at 3:10

## 1 Answer

Seems that you can set the active UV layer through the uv_textures collection rather than uv_layers:

bpy.context.object.data.uv_textures['AO'].active = True