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 31 additions and 12 deletions
Showing only changes of commit 621849ca1d - Show all commits

View File

@ -25,7 +25,9 @@ def merge_task_layer(
local_tls: list[str], local_tls: list[str],
target_file: Path, target_file: Path,
): ):
local_col = bpy.data.collections[col_base_name] local_col = bpy.data.collections.get(col_base_name)
if not local_col:
return "Current File Name doesn't contain valid task layer"
local_suffix = constants.LOCAL_SUFFIX local_suffix = constants.LOCAL_SUFFIX
external_suffix = constants.EXTERNAL_SUFFIX external_suffix = constants.EXTERNAL_SUFFIX
asset_suffix.add_suffix_to_hierarchy(local_col, local_suffix) asset_suffix.add_suffix_to_hierarchy(local_col, local_suffix)

View File

@ -5,13 +5,15 @@ from pathlib import Path
from . import transferable_data, constants from . import transferable_data, constants
def get_parent_col_name():
return "CH-chr_test" # TODO Replace Hard Coded Value
def get_task_layer_name_from_file(self): def get_task_layer_name_from_file(self):
file_name = bpy.path.basename(bpy.context.blend_data.filepath) file_name = bpy.path.basename(bpy.context.blend_data.filepath)
task_layer_name = file_name.split(".")[-2] task_layer_name = file_name.split(".")[-2]
if task_layer_name not in constants.TASK_LAYER_KEYS: if task_layer_name in constants.TASK_LAYER_KEYS:
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer") return task_layer_name
return {'CANCELLED'}
return task_layer_name
class ASSETPIPE_OT_update_ownership(bpy.types.Operator): class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
@ -21,6 +23,9 @@ class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = context.active_object obj = context.active_object
task_layer_name = get_task_layer_name_from_file(self) task_layer_name = get_task_layer_name_from_file(self)
if not task_layer_name:
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer")
return {'CANCELLED'}
transferable_data.vertex_groups_update(obj, task_layer_name) transferable_data.vertex_groups_update(obj, task_layer_name)
transferable_data.modifiers_update(obj, task_layer_name) transferable_data.modifiers_update(obj, task_layer_name)
transferable_data.material_slot_update(obj, task_layer_name) transferable_data.material_slot_update(obj, task_layer_name)
@ -33,9 +38,11 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
def execute(self, context): def execute(self, context):
# Find current task Layer # Find current task Layer
col_base_name = "CH-chr_test" # TODO replace hard coded value
current_file = Path(bpy.data.filepath) current_file = Path(bpy.data.filepath)
task_layer_name = get_task_layer_name_from_file(self) task_layer_name = get_task_layer_name_from_file(self)
if not task_layer_name:
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer")
return {'CANCELLED'}
pub_file = core.find_published_file(current_file) pub_file = core.find_published_file(current_file)
pub_file_path = pub_file.__str__() pub_file_path = pub_file.__str__()
bpy.ops.wm.open_mainfile(filepath=pub_file_path) bpy.ops.wm.open_mainfile(filepath=pub_file_path)
@ -44,15 +51,19 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
item for item in constants.TASK_LAYER_KEYS if item != task_layer_name item for item in constants.TASK_LAYER_KEYS if item != task_layer_name
] ]
core.merge_task_layer( error_msg = core.merge_task_layer(
context, context,
col_base_name=col_base_name, col_base_name=get_parent_col_name(),
local_tls=local_tls, local_tls=local_tls,
target_file=current_file, target_file=current_file,
) )
if error_msg:
bpy.ops.wm.open_mainfile(filepath=current_file.__str__())
self.report({'ERROR'}, error_msg)
return {'CANCELLED'}
bpy.ops.wm.save_as_mainfile(filepath=pub_file_path) bpy.ops.wm.save_as_mainfile(filepath=pub_file_path)
bpy.ops.wm.open_mainfile(filepath=current_file.__str__()) bpy.ops.wm.open_mainfile(filepath=current_file.__str__())
return {'FINISHED'} return {'FINISHED'}
@ -62,14 +73,20 @@ class ASSETPIPE_OT_pull_test(bpy.types.Operator):
def execute(self, context): def execute(self, context):
task_layer_name = get_task_layer_name_from_file(self) task_layer_name = get_task_layer_name_from_file(self)
if not task_layer_name:
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer")
return {'CANCELLED'}
pub_file = core.find_published_file(Path(bpy.data.filepath)) pub_file = core.find_published_file(Path(bpy.data.filepath))
col_base_name = "CH-chr_test" # TODO replace hard coded value error_msg = core.merge_task_layer(
core.merge_task_layer(
context, context,
col_base_name=col_base_name, col_base_name=get_parent_col_name(),
local_tls=[task_layer_name], local_tls=[task_layer_name],
target_file=pub_file, target_file=pub_file,
) )
if error_msg:
self.report({'ERROR'}, error_msg)
return {'CANCELLED'}
return {'FINISHED'} return {'FINISHED'}