3

I have a scene with a few thousands objects and part of them, randomly, have 2 or 3 UV sets. I need to keep just the active UV because when exported in fbx they get mixed. Thanks!

bestelix
  • 125
  • 9

3 Answers3

7

Script

Removes non active uv layers from all meshes in blend. As with all scripts that remove things, save first.

import bpy

for me in bpy.data.meshes:
    uvs = [uv for uv in me.uv_layers 
            if uv !=  me.uv_layers.active]
    while uvs:
        me.uv_layers.remove(uvs.pop())

Removes all uv layers not marked active render.

import bpy

for me in bpy.data.meshes:
    uvs = [uv for uv in me.uv_layers
            if not uv.active_render]
    while uvs:
        me.uv_layers.remove(uvs.pop())
batFINGER
  • 84,216
  • 10
  • 108
  • 233
  • Thanks! works great but I realized that "active" means highlighted in the uvmap list but wanted to keep the "active for rendering" one. Can you tell me what to change? – bestelix Feb 23 '19 at 16:27
  • NP added edit to remove all uvs not marked active_render – batFINGER Feb 24 '19 at 08:32
0

If you really have thousands of objects than use code. For single use you can delete them under the Object Data Tab in the Properties Panel. Go into edit mode, select your mesh and click on the different UVMaps to figure out which one is empty. Hit the minus button to delete it.

enter image description here

AzulShiva
  • 835
  • 1
  • 15
  • 35
  • Thanks but I know how to do it manualy. Is just that I can't do it for all selected objects from the interface. – bestelix Feb 23 '19 at 17:03
0

For people who find this thread when searching for a way to simply delete UVs on all objects. I edited batFINGER's script to do just that.

import bpy

for me in bpy.data.meshes: uvs = [uv for uv in me.uv_layers if uv != me.uv_layers] while uvs: me.uv_layers.remove(uvs.pop())

pomit
  • 1