I am trying to automate the process of removing all UV layers except for one named 'baked' on an active object. looking online I can only see answers using data.uv_textures, something that changed in Blender's API.

I am very new to scripting and don't really understand how to read and use the Blender Documentation

I would like to go from enter image description here

to this enter image description here

Also, Any tips of how to use the blender documentation will be greatly appreciated. thanks.

  • $\begingroup$ Tips on how to use the blender documentation? What do you mean? $\endgroup$
    – TheLabCat
    Commented Apr 20, 2021 at 2:50
  • $\begingroup$ Just trying to work with it and it feels very confusing, again, I don't really know coding so it might be a dumb request. MeshUVLoopLayer or UVLoopLayer for instance, $\endgroup$
    – Ebi
    Commented Apr 20, 2021 at 3:45
  • $\begingroup$ Well, I already know Python and I was getting confused by the Blender API, but it’s not really all that hard. Mostly just finding out where stuff is. However, if you have no coding experience at all, “consider purchasing a better microphone.” Try SoloLearn for free introductory Python courses. $\endgroup$
    – TheLabCat
    Commented Apr 20, 2021 at 3:45
  • $\begingroup$ I might need to get a better mic... 😬 $\endgroup$
    – Ebi
    Commented Apr 20, 2021 at 6:56

1 Answer 1


Based on @batFINGER answer

The following allows for passing either a single string of a uv_map name to keep or a list of names to keep.

Since the function rem_uvs takes a parameter reference of the object a check is made to ensure the object is a mesh type (which may have uv_maps). Attempts to iterate through objects that do not include data.uv_layers would cause AttributeError and the script would fail.

In order to avoid errors caused when modifying a loop control all items that are intended to be removed are 1st added to their own list. That list is then used to remove the uv_maps from the object.

Be sure to only use one of the 2 function calls at a time or include the single name in the list of names.

import bpy

def rem_uvs(uvs_to_keep, ob):
    uvs_to_rem = []
    if type(uvs_to_keep) == 'str':
        uvs_to_keep = list(uvs_to_keep)
    if ob.type != 'MESH':
    for uv in ob.data.uv_layers:
        if uv.name in uvs_to_keep:
    while uvs_to_rem:

# providing single name to keep
rem_uvs("baked", bpy.context.object)

# providing list of names to keep
names = [
#rem_uvs(names, bpy.context.object)
  • $\begingroup$ thanks a lot for the detailed answer, that works like a charm. And the list option is a great addition i didn't think of 😃 $\endgroup$
    – Ebi
    Commented Apr 20, 2021 at 6:54
  • $\begingroup$ Done, @Ratt ;). $\endgroup$
    – Ebi
    Commented Apr 20, 2021 at 9:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .