Asset Pipeline v2 #145
@ -49,80 +49,52 @@ def update_task_layer_objects(
|
|||||||
target_col.objects.link(transfer_obj)
|
target_col.objects.link(transfer_obj)
|
||||||
|
|
||||||
|
|
||||||
def push_task_layer(
|
def merge_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(
|
|
||||||
context: bpy.types.Context,
|
context: bpy.types.Context,
|
||||||
col_base_name: str,
|
col_base_name: str,
|
||||||
current_tls: list[str],
|
local_tls: list[str],
|
||||||
target_file: Path,
|
target_file: Path,
|
||||||
):
|
):
|
||||||
current_task_col = bpy.data.collections[col_base_name]
|
local_col = bpy.data.collections[col_base_name]
|
||||||
current_suffix = "TASK"
|
local_suffix = "LOCAL"
|
||||||
source_suffix = "PUBLISH"
|
source_suffix = "SOURCE"
|
||||||
target_suffix = "TARGET"
|
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)
|
import_data_from_lib(target_file, "collections", col_base_name)
|
||||||
appended_col = bpy.data.collections[col_base_name] # find appended data
|
appended_col = bpy.data.collections[col_base_name] # find appended data
|
||||||
asset_suffix.add_suffix_to_hierarchy(appended_col, source_suffix)
|
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}"]
|
source_col = bpy.data.collections[f"{col_base_name}.{source_suffix}"]
|
||||||
target_col = bpy.data.collections.new(f"{col_base_name}.{target_suffix}")
|
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)
|
||||||
context.scene.collection.children.unlink(current_col)
|
context.scene.collection.children.unlink(local_col)
|
||||||
|
|
||||||
# Find Obj owned by other Current Task Layer
|
# Find Obj owned by other Current 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 not in current_tls:
|
if obj.asset_id_owner not in local_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 not in current_tls:
|
if item.owner not in local_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 = []
|
local_objs = []
|
||||||
current_transfer_data = []
|
local_transfer_data = []
|
||||||
for obj in current_col.objects:
|
for obj in local_col.objects:
|
||||||
if obj.asset_id_owner in current_tls:
|
if obj.asset_id_owner in local_tls:
|
||||||
current_transfer_objs.append(obj)
|
local_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 in current_tls:
|
if item.owner in local_tls:
|
||||||
current_transfer_data.append(item)
|
local_transfer_data.append(item)
|
||||||
update_task_layer_objects(target_col, current_transfer_objs)
|
update_task_layer_objects(target_col, local_objs)
|
||||||
|
|
||||||
apply_transfer_data(
|
apply_transfer_data(
|
||||||
context,
|
context,
|
||||||
@ -131,7 +103,7 @@ def pull_task_layer(
|
|||||||
)
|
)
|
||||||
apply_transfer_data(
|
apply_transfer_data(
|
||||||
context,
|
context,
|
||||||
current_transfer_data,
|
local_transfer_data,
|
||||||
target_col,
|
target_col,
|
||||||
) # TODO test if only one list of transfer data is needed
|
) # TODO test if only one list of transfer data is needed
|
||||||
bpy.ops.outliner.orphans_purge(
|
bpy.ops.outliner.orphans_purge(
|
||||||
|
@ -4,6 +4,11 @@ from . import core
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from . import asset_suffix
|
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):
|
class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
|
||||||
bl_idname = "assetpipe.update_ownership"
|
bl_idname = "assetpipe.update_ownership"
|
||||||
@ -30,17 +35,23 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
# Find current task Layer
|
# Find current task Layer
|
||||||
source_col = context.collection
|
col_base_name = "CH-chr_test" # TODO replace hard coded value
|
||||||
source_task_layer = source_col.name.split('.')[-1]
|
current_file = Path(bpy.data.filepath)
|
||||||
target_task_layer = "PUB"
|
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
|
core.merge_task_layer(
|
||||||
for col in context.scene.collection.children_recursive:
|
context,
|
||||||
if "PUB" in col.name:
|
col_base_name=col_base_name,
|
||||||
target_col = col
|
local_tls=local_tls,
|
||||||
core.push_task_layer(
|
target_file=current_file,
|
||||||
context, source_col, target_col, source_task_layer, target_task_layer
|
|
||||||
)
|
)
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=pub_file_path)
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=current_file.__str__())
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
@ -53,10 +64,10 @@ class ASSETPIPE_OT_pull_test(bpy.types.Operator):
|
|||||||
current_tl = current_file.name.split('.')[-2]
|
current_tl = current_file.name.split('.')[-2]
|
||||||
pub_file = core.find_published_file(current_file)
|
pub_file = core.find_published_file(current_file)
|
||||||
col_base_name = "CH-chr_test" # TODO replace hard coded value
|
col_base_name = "CH-chr_test" # TODO replace hard coded value
|
||||||
core.pull_task_layer(
|
core.merge_task_layer(
|
||||||
context,
|
context,
|
||||||
col_base_name=col_base_name,
|
col_base_name=col_base_name,
|
||||||
current_tls=[current_tl],
|
local_tls=[current_tl],
|
||||||
target_file=pub_file,
|
target_file=pub_file,
|
||||||
)
|
)
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
Loading…
Reference in New Issue
Block a user