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 41 additions and 58 deletions
Showing only changes of commit 49700033aa - Show all commits

View File

@ -49,80 +49,52 @@ def update_task_layer_objects(
target_col.objects.link(transfer_obj)
def push_task_layer(
context: bpy.types.Collection,
source_col: bpy.types.Collection,
current_col: bpy.types.Collection,
source_tl: str,
):
# TODO REFACTOR based on new PULL FUNCTION
# NOTE PUSHING MAY BE AS SIMPLE AS OPENING THE PUBLISH FILE AND PULLING THE CURRENT TASK LAYER IN
# Find Obj owned by Current Task Layer
transfer_objs = []
transfer_data_list = []
for source_obj in source_col.objects:
if source_obj.asset_id_owner == source_tl:
transfer_objs.append(source_obj)
# Find Transfer-Data in current TL
for item in source_obj.transfer_data_ownership:
if item.owner == source_tl:
transfer_data_list.append(item)
update_task_layer_objects(
current_col,
transfer_objs,
)
# Move transferrable data onto obj owned by others
apply_transfer_data(context, transfer_data_list, current_col)
def pull_task_layer(
def merge_task_layer(
context: bpy.types.Context,
col_base_name: str,
current_tls: list[str],
local_tls: list[str],
target_file: Path,
):
current_task_col = bpy.data.collections[col_base_name]
current_suffix = "TASK"
source_suffix = "PUBLISH"
local_col = bpy.data.collections[col_base_name]
local_suffix = "LOCAL"
source_suffix = "SOURCE"
target_suffix = "TARGET"
asset_suffix.add_suffix_to_hierarchy(current_task_col, current_suffix)
asset_suffix.add_suffix_to_hierarchy(local_col, local_suffix)
import_data_from_lib(target_file, "collections", col_base_name)
appended_col = bpy.data.collections[col_base_name] # find appended data
asset_suffix.add_suffix_to_hierarchy(appended_col, source_suffix)
current_col = bpy.data.collections[f"{col_base_name}.{current_suffix}"]
local_col = bpy.data.collections[f"{col_base_name}.{local_suffix}"]
source_col = bpy.data.collections[f"{col_base_name}.{source_suffix}"]
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)
context.scene.collection.children.unlink(current_col)
context.scene.collection.children.unlink(local_col)
# Find Obj owned by other Current Task Layer
source_transfer_objs = []
source_transfer_data = []
for obj in source_col.objects:
if obj.asset_id_owner not in current_tls:
if obj.asset_id_owner not in local_tls:
source_transfer_objs.append(obj)
# Find Transfer-Data in other Task Layers
for item in obj.transfer_data_ownership:
if item.owner not in current_tls:
if item.owner not in local_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 in current_tls:
current_transfer_objs.append(obj)
local_objs = []
local_transfer_data = []
for obj in local_col.objects:
if obj.asset_id_owner in local_tls:
local_objs.append(obj)
# Find Transfer-Data in other Task Layers
for item in obj.transfer_data_ownership:
if item.owner in current_tls:
current_transfer_data.append(item)
update_task_layer_objects(target_col, current_transfer_objs)
if item.owner in local_tls:
local_transfer_data.append(item)
update_task_layer_objects(target_col, local_objs)
apply_transfer_data(
context,
@ -131,7 +103,7 @@ def pull_task_layer(
)
apply_transfer_data(
context,
current_transfer_data,
local_transfer_data,
target_col,
) # TODO test if only one list of transfer data is needed
bpy.ops.outliner.orphans_purge(

View File

@ -4,6 +4,11 @@ from . import core
from pathlib import Path
from . import asset_suffix
TASK_LAYER_TYPES = [
'RIG',
'MODEL',
] # TODO Tie this into props and generate based on JSON file instead
class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
bl_idname = "assetpipe.update_ownership"
@ -30,17 +35,23 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
def execute(self, context):
# Find current task Layer
source_col = context.collection
source_task_layer = source_col.name.split('.')[-1]
target_task_layer = "PUB"
col_base_name = "CH-chr_test" # TODO replace hard coded value
current_file = Path(bpy.data.filepath)
current_tl = current_file.name.split('.')[-2]
pub_file = core.find_published_file(current_file)
pub_file_path = pub_file.__str__()
bpy.ops.wm.open_mainfile(filepath=pub_file_path)
local_tls = [tl for tl in TASK_LAYER_TYPES if tl != current_tl]
# Find PUBLUSH Collection
for col in context.scene.collection.children_recursive:
if "PUB" in col.name:
target_col = col
core.push_task_layer(
context, source_col, target_col, source_task_layer, target_task_layer
core.merge_task_layer(
context,
col_base_name=col_base_name,
local_tls=local_tls,
target_file=current_file,
)
bpy.ops.wm.save_as_mainfile(filepath=pub_file_path)
bpy.ops.wm.open_mainfile(filepath=current_file.__str__())
return {'FINISHED'}
@ -53,10 +64,10 @@ class ASSETPIPE_OT_pull_test(bpy.types.Operator):
current_tl = current_file.name.split('.')[-2]
pub_file = core.find_published_file(current_file)
col_base_name = "CH-chr_test" # TODO replace hard coded value
core.pull_task_layer(
core.merge_task_layer(
context,
col_base_name=col_base_name,
current_tls=[current_tl],
local_tls=[current_tl],
target_file=pub_file,
)
return {'FINISHED'}