Asset Pipeline v2 #145
@ -16,9 +16,10 @@ def get_task_layer_name_from_file():
|
||||
return task_layer_name
|
||||
|
||||
|
||||
class ASSETPIPE_OT_push_test(bpy.types.Operator):
|
||||
bl_idname = "assetpipe.push_test"
|
||||
bl_label = 'Push to Publish'
|
||||
class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
|
||||
bl_idname = "assetpipe.sync_with_publish"
|
||||
bl_label = "Sync with Publish"
|
||||
bl_description = """Push and or Pull data from Published file. Will prompt with a list of new data found before pushing"""
|
||||
|
||||
_new_transfer_data = {}
|
||||
|
||||
@ -34,6 +35,10 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
|
||||
description="Pull in any new data from the Published file before Pushing",
|
||||
)
|
||||
|
||||
push: bpy.props.BoolProperty(
|
||||
name="Push", default=True, description="Push any new data to Published file"
|
||||
)
|
||||
|
||||
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
|
||||
local_col = bpy.data.collections.get(get_parent_col_name())
|
||||
if not local_col:
|
||||
@ -65,7 +70,8 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
|
||||
layout = self.layout
|
||||
|
||||
row = layout.row()
|
||||
row.prop(self, "pull")
|
||||
if self.push:
|
||||
row.prop(self, "pull")
|
||||
row.prop(self, "save")
|
||||
|
||||
if self._new_transfer_data:
|
||||
@ -103,6 +109,9 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
|
||||
if self.save:
|
||||
bpy.ops.wm.save_as_mainfile(filepath=current_file.__str__())
|
||||
|
||||
if not self.push:
|
||||
return {'FINISHED'}
|
||||
|
||||
bpy.ops.wm.open_mainfile(filepath=pub_file_path)
|
||||
|
||||
local_tls = [
|
||||
@ -125,33 +134,7 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class ASSETPIPE_OT_pull_test(bpy.types.Operator):
|
||||
bl_idname = "assetpipe.pull_test"
|
||||
bl_label = 'Pull from Publish'
|
||||
|
||||
def execute(self, context: bpy.types.Context):
|
||||
task_layer_name = get_task_layer_name_from_file()
|
||||
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))
|
||||
error_msg = core.merge_task_layer(
|
||||
context,
|
||||
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'}
|
||||
|
||||
|
||||
classes = (
|
||||
ASSETPIPE_OT_push_test,
|
||||
ASSETPIPE_OT_pull_test,
|
||||
)
|
||||
classes = (ASSETPIPE_OT_sync_with_publish,)
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -12,8 +12,12 @@ class ASSETPIPE_PT_TestUI(bpy.types.Panel):
|
||||
text=f"Active Task Layer: {context.collection.name.split('.')[-1]}"
|
||||
)
|
||||
self.layout.label(text="Test UI")
|
||||
self.layout.operator("assetpipe.push_test", icon="TRIA_UP")
|
||||
self.layout.operator("assetpipe.pull_test", icon="TRIA_DOWN")
|
||||
self.layout.operator(
|
||||
"assetpipe.sync_with_publish", text="Push to Publish", icon="TRIA_UP"
|
||||
).push = True
|
||||
self.layout.operator(
|
||||
"assetpipe.sync_with_publish", text="Pull from Publish", icon="TRIA_DOWN"
|
||||
).push = False
|
||||
|
||||
if not context.active_object:
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user