My first tutorial from the series ‘Quick Tips That Don't Interrupt Your Music’. You can mute the sound and continue enjoying your music if you want.
I have created a Python script that allows you to apply Smart UV Unwrap to the objects in an entire collection. A separate UV map is created for each object. You can find the script here:
import bpy
angle_limit = 66
island_margin = 0.03
area_weight = 0.0
correct_aspect = True
scale_to_bounds = True
if bpy.context.mode != 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')
alc = bpy.context.view_layer.active_layer_collection
if alc:
collection = alc.collection
def gather_objects_recursive(col, out_set):
for o in col.objects:
out_set.add(o)
for child in col.children:
gather_objects_recursive(child, out_set)
return out_set
all_objs = list(gather_objects_recursive(collection, set()))
bpy.ops.object.select_all(action='DESELECT')
for obj in all_objs:
if obj.type != 'MESH':
continue
obj.select_set(True)
bpy.context.view_layer.objects.active = obj
try:
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.uv.smart_project(
angle_limit=angle_limit,
island_margin=island_margin,
area_weight=area_weight,
correct_aspect=correct_aspect,
scale_to_bounds=scale_to_bounds
)
except:
pass
finally:
if bpy.context.mode != 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')
obj.select_set(False)