Delete inactive uv_layers

Hello,

I need to remove all unused uv maps from my project. I have over 3800 Objects and each of them with about 10 inactive layers, of course, I do not want to remove them by hand :slight_smile:

I have the following code, but I can not seem to find a method to delete the uv layer:



import bpy
   
for object in bpy.data.objects:
    for uv in object.data.uv_layers:
        object.data.uv_layers.active_index=1            
        if(object.data.uv_layers[0]!=uv):
            print(uv.name)



I tried โ€ฆ

uv.delete()
uv.remove()
uv_layers.pop()

nothing works. In the documentation (http://www.blender.org/documentation/blender_python_api_2_63_2/bpy.types.MeshUVLoopLayer.html) there is no according method listed, but I am sure, there must be a method to delete a uv layer.

For those who want to know: I have to delete the unused uv layers, because the jmonkey engine seems to have problems with them, as it can not display objects with unused uv_layers.

Thanks to anyone who can help, much appreciated!

.remove() the corresponding uv_textures layer

Thanks, I tried and it works. Hereโ€™s my Code:


import bpy   
for object in bpy.data.objects:
    for uv in object.data.uv_textures:
        if(uv!=object.data.uv_textures[0]):            
            object.data.uv_textures.remove(layer=uv)



Thanks a lot!!