2.8 Texture atlas (missing feature)

…just texted the script, does what it has to do. Major issues still persist though: when i select all the objects and enter Multiple edit mode, i can switch the UVMap i want to edit… but it works only on the originally Active object! So i am actually editing UVMap2 for the active object and UVMap1 for all the others objects i selected :\

1 Like

…trying to mass switch active UVMap on selected objects…have no experience at all in Python, tryed the following but it is not working. Could please have a look at it? Thanks!!

import bpy

meshes = {obj.data for obj in bpy.context.selected_objects if obj.type == 'MESH'}

for mesh in meshes:
    mesh.uv_textures['UVMapAO'].active = True

For this addon I wrote a modified uv panel that has the functions you mentioned along with reordering uv maps.

If you want to take a look at the code, it’s in mesh_tools.py
look for these operators:
BatchSetActiveUVMapByIndex
BatchSetActiveUVMapByName
BatchAddUVMap

You’re script fails because in 2.80 mesh.uv_textures got changed to mesh.uv_layers

1 Like

Hey thanks so much, found and adapted the BatchSetActiveUVMapByIndex script bits, really useful when baking stuff :slight_smile:

Hi there,
Is it possible to merge objects and separate them later? an alternative to TextureAtlas? It is important for me to export several objects as one and to import them again later and to transfer properties and to separate the original again.

regards,
Manu

found this to replace the persistent grouping similar to Texture Atlas

I also just integrated a little uv tool to my Addon just yesterday. It’s not yet in the release but you could download the master and install the zip if you want

Hi irSindaco, here I am, another poor guy who need the same features that you described, did you find an easy solution to this problem that doesn’t require coding during this time?

Indeed it’s infuriating how multi edit works (or doesn’t work, actually) with UV editing and how much we need the same functionality present in the texture atlas addon.

The default, expected behaviour for multi object editing and UV’s would be to add/remove/rename UV’s while in multi edit mode which should transfer to ALL of the selected objects, and be able to switch the active UV for all the selected objects as well. Right now multi editing is pretty much useless with UV’s and more than one channel.

Hi! I currently use a set of 3 small python scripts to automate add/remove/rename UV’s and to switch the active UV to a selected index, less than ideal but works.
Still have to find time to make small addon out of these simple scripts, maybe one day…Well, I usually customize the following based on specific tasks, maybe you can find a use for them:

RENAME:

import bpy
for obj in bpy.context.selected_objects :
    for uvmap in  obj.data.uv_layers :
        uvmap.name = 'UVMap'

SET ACTIVE BY INDEX

import bpy
scene = bpy.context.scene
object = bpy.context.active_object
selected_objects = bpy.context.selected_objects
uvmaps = object.data.uv_layers
if len (uvmaps) > 0:
    active_uv_map_index = uvmaps.active_index    
    for obj in selected_objects:
        if obj.type == 'MESH':
            uv_maps = obj.data.uv_layers
            if len (uv_maps) > 0:                
                        uv_maps[0].active = True

ADD UV MAP AND SET ACTIVE

import bpy
scene = bpy.context.scene
object = bpy.context.active_object
selected_objects = bpy.context.selected_objects
uv_map_name = 'UVMapAO'
meshes = {obj.data for obj in bpy.context.selected_objects if obj.type == 'MESH'}
for mesh in meshes:
    mesh.uv_layers.new(name=uv_map_name) 
uvmaps = object.data.uv_layers
if len (uvmaps) > 0:
    active_uv_map_index = uvmaps.active_index    
    for obj in selected_objects:
        if obj.type == 'MESH':
            uv_maps = obj.data.uv_layers
            if len (uv_maps) > 0:                
                        uv_maps[1].active = True

Well…I have to admit that I don’t have any experience in coding, I don’t, to be honest, I wouldn’t even know what to do with these scripts.
Could you suggest me some tutorial or some kind of instruction on how to use it?

In any case, I would like to thank you for your time.
Thank you irSindaco

I totally agree, for what I’d need I find quite frustrating not be able to use anymore “Texture atlas addon” and all his features.
I didn’t verified yet if there are some related post on https://blender.community/c/rightclickselect/ , if not we probably have to propose something and make our voice heard.

You’re welcome :slight_smile:
Here’s how to run a script:

  1. Open a Text Editor view in Blender.
  2. Press Alt + O, or go to Text>Open Text Block and open the .py file
  3. Then simply press Run script or press Alt+p

As for the things you can customize, it’s quite easy as there’s really few lines to edit here:

Rename script:
uvmap.name = ‘YourUVMapName’

Select by index:
uv_maps[YourIndex].active = True

Add uvmap and rename:
uv_map_name = ‘YourUVMapName’
uv_maps[NewMapIndex].active = True

These all work on all selected objects of MESH type.
Hope this helps!

So cool! I tried all the three, and they work pretty well actually, they get the job done! Thank you so much!
As I said I don’t have any experience in coding but I have to admit that just running these simple scripts is quite addictive!
It would be really interesting learning something more about Phyton!
Maybe one day!

But what if I had to select by the name of the UV and not by the Index number? Do you think it would be possible?
The same principle, then, might be applied to the last script, so that after the creation it would automatically select the UV layer with the assigned name.
What do you think?

I’m not a code expert myself, but i can read and improve :wink:
Will see in my spare time if i can make it work by UVMap name (think i need to loop through selected meshes, de-select all meshes that do not have such UVMapName in their sets, then set UVMapName active on the remaining selection, and loop through the operations for selected meshes/UVMaps…easy to say, not easy to code for me :P)
Starting somewhere like here:
https://docs.blender.org/api/current/bpy.types.MeshUVLoopLayer.html#bpy.types.MeshUVLoopLayer

Well…it’s yet a little bit beyond of my comprehension XD, trivially I thought that it was possible to simply change this part of the code:

active_uv_map_index = uvmaps.active_index

with other commands to be able to obtain the desired operation.
Obviously coding is not so straightforward.
Speaking of your assumption, I was thinking that another nice feature would be to be able to select all the meshes that share an UV layer that have the same name.
What do you think? do you think it would be possible?

Hi guys, hi @irSindaco,
I took the liberty to play a little with your codes, as I said I don’t have any experience with Python and coding in general, all the new codes seem to work but I don’t exclude to have broken something, so please forgive any possible noobie errors.

As you can see I was able to change something from every code:

RENAME A SPECIFIC UV LAYER

import bpy
for obj in bpy.context.selected_objects :
    for uvmap in  obj.data.uv_layers :
        if uvmap.name == "Gianni":
            uvmap.name = "Luigi"

In this one, I tried to script something that gives me the opportunity to change a specific UV layer based on the name.
So it should change the name of all the UV layers with a specific name, of all the selected objects, with another name.

SELECT UV BY NAME

import bpy
scene = bpy.context.scene
object = bpy.context.active_object
selected_objects = bpy.context.selected_objects
uv_maps = object.data.uv_layers 
for obj in selected_objects:
        if obj.type == 'MESH':
            uv_maps = obj.data.uv_layers           
            uv_maps["Gianni"].active = True

In this one, I was able to change the selection mode, so the script should select all the UVs based on the name and no more by index number.

ADD UV MAP AND SET ACTIVE

import bpy
scene = bpy.context.scene
object = bpy.context.active_object
selected_objects = bpy.context.selected_objects
uv_map_name = 'Gianni'
meshes = {obj.data for obj in bpy.context.selected_objects if obj.type == 'MESH'}
for mesh in meshes:
    mesh.uv_layers.new(name=uv_map_name) 
uv_maps = object.data.uv_layers 
for obj in selected_objects:
        if obj.type == 'MESH':
            uv_maps = obj.data.uv_layers           
            uv_maps["Gianni"].active = True

Same thing here, It will select the new UV layer according to the assigned name.

So, that’s it, what do you think?
I tried to script from scratch the code that consent to select all the objects that have a UV layer that share the same name, but I failed miserably.
If you don’t mind I will try to post the current scripts and ask for help with the last one.
Meanwhile, thanks for everything irSindaco.

Glad you made it work :slight_smile:

Hi, how can I remove all UVmap except for a specific one? (For example, active)

Did you check out my addon above? It can edit add remove or set active multiple UV’s and even generate texture atlases. It’s here on gumroad or above on git.

1 Like