4
$\begingroup$

I need to delete all UV's I have but the last one and change the name of the UV for every object selected to match. I can do it for the first but when it comes to repeating the process for all the objects selected I don't know.

$\endgroup$
1
  • $\begingroup$ If you have to do this hundreds of times maybe it is a good idea to write a python script for that $\endgroup$
    – user131425
    Commented Jun 28, 2022 at 8:05

2 Answers 2

5
$\begingroup$

Use a python for that:

import bpy

for obj in bpy.context.selected_objects:
    layers = obj.data.uv_layers
    lastLayer = obj.data.uv_layers[len(obj.data.uv_layers) - 1]
    for uv in layers:
        if uv != lastLayer:
            layers.remove(uv)
        else:
            uv.name = 'My UV name'
$\endgroup$
1
  • 2
    $\begingroup$ Hey did you test this ? This throws an error because you're removing elements from a list you're iterating over $\endgroup$
    – Gorgious
    Commented Jun 28, 2022 at 16:41
2
$\begingroup$

Another method which worked for me because the other method didn't.

import bpy

for obj in bpy.context.selected_objects:
    layers = obj.data.uv_layers
    for i in range(len(layers) - 1):
        layers.remove(layers[0])
    layers[0].name = 'My UV name'
$\endgroup$

You must log in to answer this question.

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