Help concerning a script I tried to make to Upscale UVs

Hello Everyone ! I’m new here and I’m looking for help concerning a script I tried to make for blender 4.0.2. I’ve created a script that allow me to adjusts all the UVs of the objects I selected to occupy a maximum size in a UDIM, but does not overlap the UVs so that each UV of the objects occupies a maximum size in a UDIM. Is someone can help me modify this script so that when I select several objects and I launch the script, the script allows me to superimpose the UVs individually of several selected objects and adjusts them to occupy a maximum size in a UDIM or Tile (1x1 unity). That is my Script :

import bpy
import bmesh

def scale_uvs_proportionally():
# Passe en mode objet si nécessaire
if bpy.context.mode != ‘OBJECT’:
bpy.ops.object.mode_set(mode=‘OBJECT’)

# Pour chaque objet sélectionné
for obj in bpy.context.selected_objects:
    if obj.type != 'MESH':
        continue
    
    # Active l'objet et passe en mode edit
    bpy.context.view_layer.objects.active = obj
    bpy.ops.object.mode_set(mode='EDIT')
    
    # Sélectionne tous les UVs
    bpy.ops.mesh.select_all(action='SELECT')
    
    # Passe en mode UV
    bpy.ops.mesh.select_mode(type='FACE')
    
    # Sélectionne tous les UVs
    bpy.ops.uv.select_all(action='SELECT')
    
    # Garde les proportions et met à l'échelle pour remplir l'espace UV
    bpy.ops.uv.select_all(action='SELECT')
    bpy.ops.transform.resize(
        value=(1, 1, 1),
        orient_type='GLOBAL',
        constraint_axis=(True, True, False),
        mirror=False,
        use_proportional_edit=False,
        proportional_edit_falloff='SMOOTH',
        proportional_size=1
    )
    
    # Ajuste l'échelle pour remplir l'espace UDIM
    bpy.ops.uv.minimize_stretch(iterations=100)
    
    # Centre les îles UV
    bpy.ops.uv.pack_islands(
        rotate=False,
        margin=0.001
    )
    
    # Retourne en mode objet
    bpy.ops.object.mode_set(mode='OBJECT')

class OBJECT_OT_scale_uvs_proportional(bpy.types.Operator):
bl_idname = “uv.scale_uvs_proportional”
bl_label = “Scale UVs Proportionally”
bl_options = {‘REGISTER’, ‘UNDO’}

def execute(self, context):
    scale_uvs_proportionally()
    return {'FINISHED'}

def register():
bpy.utils.register_class(OBJECT_OT_scale_uvs_proportional)

def unregister():
bpy.utils.unregister_class(OBJECT_OT_scale_uvs_proportional)

if name == “main”:
register()
bpy.ops.uv.scale_uvs_proportional()