4
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Mutant Bob Aug 22 '17 at 3:10
4
$\begingroup$

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
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.