# Original Blender Script by Zoidberg
# https://hub.virtamate.com/resources/blender-templates-to-convert-objs-exported-from-vam-into-objs-that-use-udim.24032/
# Reordered by qdaro for VAMs typical texture order
# Commented and switch to DAZ material index by Sally Whitemane
import bpy
bpy.ops.object.editmode_toggle()
bpy.context.scene.tool_settings.use_uv_select_sync = True
bpy.context.area.ui_type = 'PROPERTIES'
bpy.context.object.active_material_index = 28 # UNKNOWN / SELECT ALL?
bpy.ops.object.material_slot_select()
bpy.context.area.ui_type = 'UV'
bpy.ops.transform.translate(value=(1, 0, 0), orient_axis_ortho='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
bpy.context.area.ui_type = 'PROPERTIES'
bpy.context.object.active_material_index = 25 # EYELASHES VAM 24 - DAZ 25
bpy.ops.object.material_slot_select()
bpy.context.area.ui_type = 'UV'
bpy.ops.transform.translate(value=(1, 0, 0), orient_axis_ortho='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
bpy.context.area.ui_type = 'PROPERTIES'
bpy.context.object.active_material_index = 7 # GUMS VAM 7 - DAZ 7
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 9 # TEETH VAM 9 - DAZ 9
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 27 # INNERMOUTH VAM 26 - DAZ 27
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 26 # TONGUE VAM 25 - DAZ 26
bpy.ops.object.material_slot_select()
bpy.context.area.ui_type = 'UV'
bpy.ops.transform.translate(value=(1, 0, 0), orient_axis_ortho='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
bpy.context.area.ui_type = 'PROPERTIES'
bpy.context.object.active_material_index = 1 # EYEREFLECTION VAM 1 - DAZ 1
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 3 # LACRIMALS VAM 3 - DAZ 3
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 4 # PUPILS VAM 4 - DAZ 4
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 6 # TEARS VAM 6 - DAZ 6
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 8 # IRISES VAM 8 - DAZ 8
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 10 # CORNEA VAM 10 - DAZ 10
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 13 # SCLERA VAM 14 - DAZ 13
bpy.ops.object.material_slot_select()
bpy.context.area.ui_type = 'UV'
bpy.ops.transform.translate(value=(1, 0, 0), orient_axis_ortho='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
#bpy.context.area.ui_type = 'PROPERTIES'
#bpy.context.object.active_material_index = 28 # GENITAL VAM 28 - DOES NOT EXIST FOR DAZ
#bpy.ops.object.material_slot_select()
#bpy.context.area.ui_type = 'UV'
#bpy.ops.transform.translate(value=(1, 0, 0), orient_axis_ortho='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
bpy.context.area.ui_type = 'PROPERTIES'
bpy.context.object.active_material_index = 0 # LEGS VAM 0 - DAZ 0
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 12 # TOENAILS VAM 12 - DAZ 12
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 14 # FINGERNAILS VAM 14 - DAZ 14
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 17 # HANDS VAM 16 - DAZ 17
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 18 # SHOULDERS VAM 17 - DAZ 18
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 23 # FOREARMS VAM 22 - DAZ 23
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 24 # FEET VAM 23 - DAZ 24
bpy.ops.object.material_slot_select()
bpy.context.area.ui_type = 'UV'
bpy.ops.transform.translate(value=(1, 0, 0), orient_axis_ortho='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
bpy.context.area.ui_type = 'PROPERTIES'
bpy.context.object.active_material_index = 15 # HEAD VAM 15 - DAZ 15
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 19 # NECK VAM 18 - DAZ 19
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 20 # HIPS VAM 19 - DAZ 20
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 21 # TORSO VAM 20 - DAZ 21
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 22 # NIPPLES VAM 21 - DAZ 22
bpy.ops.object.material_slot_select()
bpy.context.object.active_material_index = 16 # EARS VAM 27 - DAZ 16
bpy.ops.object.material_slot_select()
bpy.context.area.ui_type = 'UV'
bpy.ops.transform.translate(value=(1, 0, 0), orient_axis_ortho='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
bpy.ops.mesh.select_all(action='DESELECT')
bpy.context.area.ui_type = 'TEXT_EDITOR'