Asset Pipeline v2 #145
@ -125,7 +125,7 @@ class AssetTransferMapping:
|
|||||||
return coll_map
|
return coll_map
|
||||||
|
|
||||||
def _gen_transfer_data_map(self):
|
def _gen_transfer_data_map(self):
|
||||||
context = util.get_stored_context()
|
context = bpy.context
|
||||||
transfer_data_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
transfer_data_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
||||||
temp_transfer_data = context.scene.asset_pipeline.temp_transfer_data
|
temp_transfer_data = context.scene.asset_pipeline.temp_transfer_data
|
||||||
temp_transfer_data.clear()
|
temp_transfer_data.clear()
|
||||||
|
@ -115,7 +115,6 @@ def merge_task_layer(
|
|||||||
local_tls: (list[str]): list of task layers that are local to the current file
|
local_tls: (list[str]): list of task layers that are local to the current file
|
||||||
external_file (Path): external file to pull data into the current file from
|
external_file (Path): external file to pull data into the current file from
|
||||||
"""
|
"""
|
||||||
util.set_stored_context(context=context)
|
|
||||||
local_col = context.scene.asset_pipeline.asset_collection
|
local_col = context.scene.asset_pipeline.asset_collection
|
||||||
if not local_col:
|
if not local_col:
|
||||||
return "Unable to find Asset Collection"
|
return "Unable to find Asset Collection"
|
||||||
|
@ -43,6 +43,7 @@ def transfer_vertex_group(
|
|||||||
|
|
||||||
source_obj.vertex_groups.active = source_obj.vertex_groups[vertex_group_name]
|
source_obj.vertex_groups.active = source_obj.vertex_groups[vertex_group_name]
|
||||||
# TODO Debug crashing / use context.temp_override(object=obj) style
|
# TODO Debug crashing / use context.temp_override(object=obj) style
|
||||||
|
context = bpy.context
|
||||||
override = context.copy()
|
override = context.copy()
|
||||||
override["selected_editable_objects"] = [target_obj, source_obj]
|
override["selected_editable_objects"] = [target_obj, source_obj]
|
||||||
override["active_object"] = source_obj
|
override["active_object"] = source_obj
|
||||||
@ -163,7 +164,7 @@ def init_modifiers(scene, obj):
|
|||||||
|
|
||||||
def transfer_modifier(modifier_name, target_obj, source_obj):
|
def transfer_modifier(modifier_name, target_obj, source_obj):
|
||||||
# remove old and sync existing modifiers
|
# remove old and sync existing modifiers
|
||||||
context = util.get_stored_context()
|
context = bpy.context
|
||||||
old_mod = target_obj.modifiers.get(modifier_name)
|
old_mod = target_obj.modifiers.get(modifier_name)
|
||||||
if old_mod:
|
if old_mod:
|
||||||
target_obj.modifiers.remove(old_mod)
|
target_obj.modifiers.remove(old_mod)
|
||||||
@ -233,7 +234,7 @@ def init_constraints(scene, obj):
|
|||||||
|
|
||||||
|
|
||||||
def transfer_constraint(constraint_name, target_obj, source_obj):
|
def transfer_constraint(constraint_name, target_obj, source_obj):
|
||||||
context = util.get_stored_context()
|
context = bpy.context
|
||||||
# remove old and sync existing modifiers
|
# remove old and sync existing modifiers
|
||||||
old_mod = target_obj.constraints.get(constraint_name)
|
old_mod = target_obj.constraints.get(constraint_name)
|
||||||
if old_mod:
|
if old_mod:
|
||||||
@ -276,7 +277,7 @@ 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 = util.get_stored_context()
|
context = bpy.context
|
||||||
transfer_data_list = transfer_core.get_transfer_data_as_names(
|
transfer_data_list = transfer_core.get_transfer_data_as_names(
|
||||||
obj.transfer_data_ownership, constants.MATERIAL_SLOT_KEY
|
obj.transfer_data_ownership, constants.MATERIAL_SLOT_KEY
|
||||||
)
|
)
|
||||||
@ -302,7 +303,7 @@ 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 = util.get_stored_context()
|
context = bpy.context
|
||||||
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:
|
||||||
@ -394,7 +395,7 @@ def shape_key_closest_tri_on_face(tris_dict, face, p):
|
|||||||
|
|
||||||
|
|
||||||
def shape_keys_clean(obj):
|
def shape_keys_clean(obj):
|
||||||
context = util.get_stored_context()
|
context = bpy.context
|
||||||
if obj.type != "MESH" or obj.data.shape_keys is None:
|
if obj.type != "MESH" or obj.data.shape_keys is None:
|
||||||
return
|
return
|
||||||
transfer_data_list = transfer_core.get_transfer_data_as_names(
|
transfer_data_list = transfer_core.get_transfer_data_as_names(
|
||||||
|
@ -99,16 +99,3 @@ def traverse_collection_tree(
|
|||||||
yield collection
|
yield collection
|
||||||
for child in collection.children:
|
for child in collection.children:
|
||||||
yield from traverse_collection_tree(child)
|
yield from traverse_collection_tree(child)
|
||||||
|
|
||||||
|
|
||||||
stored_context = None
|
|
||||||
|
|
||||||
|
|
||||||
def set_stored_context(context):
|
|
||||||
global stored_context
|
|
||||||
stored_context = context
|
|
||||||
|
|
||||||
|
|
||||||
def get_stored_context():
|
|
||||||
global stored_context
|
|
||||||
return stored_context
|
|
||||||
|
Loading…
Reference in New Issue
Block a user