I making a script that iterates through all of the selected objects, selects verts by the material and does a quick uv unwrap. I’m having trouble selecting the material slot though.
import bpy
for i in bpy.context.selected_objects:
bpy.ops.object.editmode_toggle()
#assign all selected scene objects to context
bpy.context.scene.objects.active = i
bpy.ops.mesh.select_all(action = 'DESELECT')
#need to assign the active material to slot 1
#????
bpy.ops.object.material_slot_select()
bpy.ops.uv.unwrap(method = 'ANGLE_BASED')
bpy.ops.object.editmode_toggle()[