Asset Pipeline v2 #145

Closed
Nick Alberelli wants to merge 431 commits from (deleted):feature/asset-pipeline-v2 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 14 additions and 13 deletions
Showing only changes of commit 7df6d5a6df - Show all commits

View File

@ -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_data_ownership = target_obj.transfer_data_ownership
transfer_items_names = [item.name for item in transfer_data_ownership] transfer_items_names = [item.name for item in transfer_data_ownership]
if transfer_data_item.name not in transfer_items_names: 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 = transfer_data_ownership.add()
new_item.name = transfer_data_item.name new_item.name = transfer_data_item.name
new_item.owner = transfer_data_item.owner new_item.owner = transfer_data_item.owner
new_item.type = transfer_data_item.type new_item.type = transfer_data_item.type
new_item.id = bpy.data.objects[ new_item.id = bpy.data.objects[target_obj.name]
id_name
] # TODO replace this pointer with a a string instead
def apply_transfer_data( def apply_transfer_data(
@ -25,7 +22,9 @@ def apply_transfer_data(
): ):
for item in transfer_data_list: for item in transfer_data_list:
for target_obj in target_col.objects: 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!") print(f"{target_obj.name}: READY TO TRANSFER BABY!")
transfer_functions.transfer_vertex_group( transfer_functions.transfer_vertex_group(
context=context, context=context,
@ -45,7 +44,7 @@ def update_task_layer_objects(
): ):
# Link new obj to collection # Link new obj to collection
for transfer_obj in transfer_objs: 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}" transfer_obj.name = f"{obj_root_name}"
target_col.objects.link(transfer_obj) target_col.objects.link(transfer_obj)
@ -82,7 +81,7 @@ def pull_task_layer(
context: bpy.types.Context, context: bpy.types.Context,
current_task_col: bpy.types.Collection, current_task_col: bpy.types.Collection,
col_base_name: str, col_base_name: str,
current_tl: str, current_tls: list[str],
target_col: bpy.types.Collection, target_col: bpy.types.Collection,
): ):
current_suffix = "TASK" current_suffix = "TASK"
@ -99,7 +98,7 @@ def pull_task_layer(
current_col = bpy.data.collections[f"{col_base_name}.{current_suffix}"] current_col = bpy.data.collections[f"{col_base_name}.{current_suffix}"]
source_col = bpy.data.collections[f"{col_base_name}.{source_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 # Link Target as new Active Collection
context.scene.collection.children.link(target_col) context.scene.collection.children.link(target_col)
@ -109,22 +108,22 @@ def pull_task_layer(
source_transfer_objs = [] source_transfer_objs = []
source_transfer_data = [] source_transfer_data = []
for obj in source_col.objects: 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) source_transfer_objs.append(obj)
# Find Transfer-Data in other Task Layers # Find Transfer-Data in other Task Layers
for item in obj.transfer_data_ownership: for item in obj.transfer_data_ownership:
if item.owner != current_tl: if item.owner not in current_tls:
source_transfer_data.append(item) source_transfer_data.append(item)
update_task_layer_objects(target_col, source_transfer_objs) update_task_layer_objects(target_col, source_transfer_objs)
current_transfer_objs = [] current_transfer_objs = []
current_transfer_data = [] current_transfer_data = []
for obj in current_col.objects: 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) current_transfer_objs.append(obj)
# Find Transfer-Data in other Task Layers # Find Transfer-Data in other Task Layers
for item in obj.transfer_data_ownership: for item in obj.transfer_data_ownership:
if item.owner == current_tl: if item.owner in current_tls:
current_transfer_data.append(item) current_transfer_data.append(item)
update_task_layer_objects(target_col, current_transfer_objs) update_task_layer_objects(target_col, current_transfer_objs)
@ -141,6 +140,7 @@ def pull_task_layer(
bpy.ops.outliner.orphans_purge( bpy.ops.outliner.orphans_purge(
do_local_ids=True, do_linked_ids=False, do_recursive=True 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): def find_published_file_version(file):

View File

@ -49,13 +49,14 @@ class ASSETPIPE_OT_pull_test(bpy.types.Operator):
bl_label = 'Pull from Publish' bl_label = 'Pull from Publish'
def execute(self, context): 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 col_base_name = "CH-chr_test" # TODO replace hard coded value
current_task_col = bpy.data.collections[col_base_name] current_task_col = bpy.data.collections[col_base_name]
core.pull_task_layer( core.pull_task_layer(
context, context,
current_task_col=current_task_col, current_task_col=current_task_col,
col_base_name=col_base_name, col_base_name=col_base_name,
current_tls=[current_tl],
current_tl="MODEL", current_tl="MODEL",
) )
return {'FINISHED'} return {'FINISHED'}