Asset Pipeline v2 #145
@ -8,14 +8,11 @@ def update_transfer_data_ownership(transfer_data_item, target_obj: bpy.types.Obj
|
||||
transfer_data_ownership = target_obj.transfer_data_ownership
|
||||
transfer_items_names = [item.name for item in transfer_data_ownership]
|
||||
if transfer_data_item.name not in transfer_items_names:
|
||||
id_name = asset_suffix.get_asset_basename(transfer_data_item.id.name)
|
||||
new_item = transfer_data_ownership.add()
|
||||
new_item.name = transfer_data_item.name
|
||||
new_item.owner = transfer_data_item.owner
|
||||
new_item.type = transfer_data_item.type
|
||||
new_item.id = bpy.data.objects[
|
||||
id_name
|
||||
] # TODO replace this pointer with a a string instead
|
||||
new_item.id = bpy.data.objects[target_obj.name]
|
||||
|
||||
|
||||
def apply_transfer_data(
|
||||
@ -25,7 +22,9 @@ def apply_transfer_data(
|
||||
):
|
||||
for item in transfer_data_list:
|
||||
for target_obj in target_col.objects:
|
||||
if target_obj.name == asset_suffix.get_asset_basename(item.id.name):
|
||||
if asset_suffix.get_asset_basename(
|
||||
target_obj.name
|
||||
) == asset_suffix.get_asset_basename(item.id.name):
|
||||
print(f"{target_obj.name}: READY TO TRANSFER BABY!")
|
||||
transfer_functions.transfer_vertex_group(
|
||||
context=context,
|
||||
@ -45,7 +44,7 @@ def update_task_layer_objects(
|
||||
):
|
||||
# Link new obj to collection
|
||||
for transfer_obj in transfer_objs:
|
||||
obj_root_name = asset_suffix.get_asset_basename(transfer_obj.name)
|
||||
obj_root_name = transfer_obj.name
|
||||
transfer_obj.name = f"{obj_root_name}"
|
||||
target_col.objects.link(transfer_obj)
|
||||
|
||||
@ -82,7 +81,7 @@ def pull_task_layer(
|
||||
context: bpy.types.Context,
|
||||
current_task_col: bpy.types.Collection,
|
||||
col_base_name: str,
|
||||
current_tl: str,
|
||||
current_tls: list[str],
|
||||
target_col: bpy.types.Collection,
|
||||
):
|
||||
current_suffix = "TASK"
|
||||
@ -99,7 +98,7 @@ def pull_task_layer(
|
||||
|
||||
current_col = bpy.data.collections[f"{col_base_name}.{current_suffix}"]
|
||||
source_col = bpy.data.collections[f"{col_base_name}.{source_suffix}"]
|
||||
target_col = bpy.data.collections.new(col_base_name)
|
||||
target_col = bpy.data.collections.new(f"{col_base_name}.{target_suffix}")
|
||||
|
||||
# Link Target as new Active Collection
|
||||
context.scene.collection.children.link(target_col)
|
||||
@ -109,22 +108,22 @@ def pull_task_layer(
|
||||
source_transfer_objs = []
|
||||
source_transfer_data = []
|
||||
for obj in source_col.objects:
|
||||
if obj.asset_id_owner != current_tl:
|
||||
if obj.asset_id_owner not in current_tls:
|
||||
source_transfer_objs.append(obj)
|
||||
# Find Transfer-Data in other Task Layers
|
||||
for item in obj.transfer_data_ownership:
|
||||
if item.owner != current_tl:
|
||||
if item.owner not in current_tls:
|
||||
source_transfer_data.append(item)
|
||||
update_task_layer_objects(target_col, source_transfer_objs)
|
||||
|
||||
current_transfer_objs = []
|
||||
current_transfer_data = []
|
||||
for obj in current_col.objects:
|
||||
if obj.asset_id_owner == current_tl:
|
||||
if obj.asset_id_owner in current_tls:
|
||||
current_transfer_objs.append(obj)
|
||||
# Find Transfer-Data in other Task Layers
|
||||
for item in obj.transfer_data_ownership:
|
||||
if item.owner == current_tl:
|
||||
if item.owner in current_tls:
|
||||
current_transfer_data.append(item)
|
||||
update_task_layer_objects(target_col, current_transfer_objs)
|
||||
|
||||
@ -141,6 +140,7 @@ def pull_task_layer(
|
||||
bpy.ops.outliner.orphans_purge(
|
||||
do_local_ids=True, do_linked_ids=False, do_recursive=True
|
||||
)
|
||||
asset_suffix.remove_suffix_from_hierarchy(target_col)
|
||||
|
||||
|
||||
def find_published_file_version(file):
|
||||
|
@ -49,13 +49,14 @@ class ASSETPIPE_OT_pull_test(bpy.types.Operator):
|
||||
bl_label = 'Pull from Publish'
|
||||
|
||||
def execute(self, context):
|
||||
# TODO move some of this logic into the core pull function
|
||||
current_tl = current_file.name.split('.')[-2]
|
||||
col_base_name = "CH-chr_test" # TODO replace hard coded value
|
||||
current_task_col = bpy.data.collections[col_base_name]
|
||||
core.pull_task_layer(
|
||||
context,
|
||||
current_task_col=current_task_col,
|
||||
col_base_name=col_base_name,
|
||||
current_tls=[current_tl],
|
||||
current_tl="MODEL",
|
||||
)
|
||||
return {'FINISHED'}
|
||||
|
Loading…
Reference in New Issue
Block a user