Asset Pipeline v2 #145
@ -263,12 +263,14 @@ def transfer_constraint(constraint_name, target_obj, source_obj):
|
|||||||
# MATERIAL SLOT
|
# MATERIAL SLOT
|
||||||
def material_slot_clean(obj):
|
def material_slot_clean(obj):
|
||||||
# Material slots cannot use generic transfer_info_clean() function
|
# Material slots cannot use generic transfer_info_clean() function
|
||||||
|
context = bpy.context # TODO pass context here
|
||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
for mat_slot in obj.material_slots:
|
for mat_slot in obj.material_slots:
|
||||||
if not asset_suffix.get_basename(mat_slot.name) in transfer_data.keys():
|
if not asset_suffix.get_basename(mat_slot.name) in transfer_data.keys():
|
||||||
index = obj.material_slots.keys().index(mat_slot.name)
|
index = obj.material_slots.keys().index(mat_slot.name)
|
||||||
obj.active_material_index = index
|
obj.active_material_index = index
|
||||||
bpy.ops.object.material_slot_remove({"object": obj})
|
with context.temp_override(object=obj):
|
||||||
|
bpy.ops.object.material_slot_remove()
|
||||||
|
|
||||||
|
|
||||||
def material_slot_is_missing(transfer_info):
|
def material_slot_is_missing(transfer_info):
|
||||||
@ -285,11 +287,13 @@ def init_material_slots(scene, obj):
|
|||||||
|
|
||||||
def transfer_material_slot(material_slot_name, target_obj, source_obj):
|
def transfer_material_slot(material_slot_name, target_obj, source_obj):
|
||||||
# Delete existing material slot if exists
|
# Delete existing material slot if exists
|
||||||
|
context = bpy.context # TODO pass context here
|
||||||
for idx in range(len(source_obj.material_slots)):
|
for idx in range(len(source_obj.material_slots)):
|
||||||
slot = source_obj.material_slots[idx]
|
slot = source_obj.material_slots[idx]
|
||||||
if asset_suffix.get_basename(slot.material.name) == material_slot_name:
|
if asset_suffix.get_basename(slot.material.name) == material_slot_name:
|
||||||
target_obj.active_material_index = idx
|
target_obj.active_material_index = idx
|
||||||
bpy.ops.object.material_slot_remove({"object": target_obj})
|
with context.temp_override(object=target_obj):
|
||||||
|
bpy.ops.object.material_slot_remove()
|
||||||
|
|
||||||
# Transfer material slots
|
# Transfer material slots
|
||||||
|
|
||||||
@ -297,7 +301,8 @@ def transfer_material_slot(material_slot_name, target_obj, source_obj):
|
|||||||
if idx >= len(target_obj.material_slots):
|
if idx >= len(target_obj.material_slots):
|
||||||
slot = source_obj.material_slots[idx]
|
slot = source_obj.material_slots[idx]
|
||||||
if asset_suffix.get_basename(slot.material.name) == material_slot_name:
|
if asset_suffix.get_basename(slot.material.name) == material_slot_name:
|
||||||
bpy.ops.object.material_slot_add({"object": target_obj})
|
with context.temp_override(object=target_obj):
|
||||||
|
bpy.ops.object.material_slot_add()
|
||||||
target_obj.material_slots[idx].link = source_obj.material_slots[
|
target_obj.material_slots[idx].link = source_obj.material_slots[
|
||||||
idx
|
idx
|
||||||
].link
|
].link
|
||||||
|
Loading…
Reference in New Issue
Block a user