Asset Pipeline v2 #145
@ -25,7 +25,9 @@ def merge_task_layer(
|
||||
local_tls: list[str],
|
||||
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
|
||||
external_suffix = constants.EXTERNAL_SUFFIX
|
||||
asset_suffix.add_suffix_to_hierarchy(local_col, local_suffix)
|
||||
|
@ -5,13 +5,15 @@ from pathlib import Path
|
||||
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):
|
||||
file_name = bpy.path.basename(bpy.context.blend_data.filepath)
|
||||
task_layer_name = file_name.split(".")[-2]
|
||||
if task_layer_name not in constants.TASK_LAYER_KEYS:
|
||||
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer")
|
||||
return {'CANCELLED'}
|
||||
return task_layer_name
|
||||
if task_layer_name in constants.TASK_LAYER_KEYS:
|
||||
return task_layer_name
|
||||
|
||||
|
||||
class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
|
||||
@ -21,6 +23,9 @@ class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
obj = context.active_object
|
||||
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.modifiers_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):
|
||||
# Find current task Layer
|
||||
col_base_name = "CH-chr_test" # TODO replace hard coded value
|
||||
current_file = Path(bpy.data.filepath)
|
||||
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_path = pub_file.__str__()
|
||||
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
|
||||
]
|
||||
|
||||
core.merge_task_layer(
|
||||
error_msg = core.merge_task_layer(
|
||||
context,
|
||||
col_base_name=col_base_name,
|
||||
col_base_name=get_parent_col_name(),
|
||||
local_tls=local_tls,
|
||||
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.open_mainfile(filepath=current_file.__str__())
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
@ -62,14 +73,20 @@ class ASSETPIPE_OT_pull_test(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
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))
|
||||
col_base_name = "CH-chr_test" # TODO replace hard coded value
|
||||
core.merge_task_layer(
|
||||
error_msg = core.merge_task_layer(
|
||||
context,
|
||||
col_base_name=col_base_name,
|
||||
col_base_name=get_parent_col_name(),
|
||||
local_tls=[task_layer_name],
|
||||
target_file=pub_file,
|
||||
)
|
||||
|
||||
if error_msg:
|
||||
self.report({'ERROR'}, error_msg)
|
||||
return {'CANCELLED'}
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user