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.
3 changed files with 181 additions and 4 deletions
Showing only changes of commit dcfd29dfb9 - Show all commits

View File

@ -46,6 +46,7 @@ def draw_task_layer_selection(
data_owner_name,
show_all_task_layers=False,
show_local=False,
text="",
):
# TODO Simplify Arguments and add Type Hints / Doc String
if show_all_task_layers == True:
@ -54,7 +55,7 @@ def draw_task_layer_selection(
data_owner_name,
scene.asset_pipeline,
'all_task_layers',
text="",
text=text,
)
return
if (
@ -67,7 +68,7 @@ def draw_task_layer_selection(
data_owner_name,
scene.asset_pipeline,
'all_task_layers',
text="",
text=text,
)
return
else:
@ -76,5 +77,5 @@ def draw_task_layer_selection(
data_owner_name,
scene.asset_pipeline,
'local_task_layers',
text="",
text=text,
)

View File

@ -6,6 +6,7 @@ from .merge.naming import task_layer_prefix_transfer_data_update
from .merge.task_layer import (
set_local_task_layers,
draw_task_layer_selection,
get_local_task_layers,
)
from .merge.publish import get_next_published_file, find_all_published
from .images import save_images
@ -506,6 +507,179 @@ class ASSETPIPE_OT_update_surrendered_transfer_data(bpy.types.Operator):
return {'FINISHED'}
def get_task_layer_types(self, context):
return
class ASSETPIPE_OT_batch_ownership_change(bpy.types.Operator):
bl_idname = "assetpipe.batch_ownership_change"
bl_label = "Batch Re-Assign"
bl_description = """Re-Assign Ownership in a batch operation"""
name_filter: bpy.props.StringProperty(
name="Filter by Name",
description="Filter Object or Transfer Data items by name",
default="",
)
data_source: bpy.props.EnumProperty(
name="Source",
items=(
('SELECT', "Selected", "Update Selected Objects Only"),
('ALL', "All", "Update All Objects"),
),
)
data_status: bpy.props.EnumProperty(
name="Owner Status",
items=(
('OWNED', "Owned", "Only objects that already have assignment"),
('ALL', "Any", "Set Ownership on any objects, even without an owner"),
),
)
owner_filter: bpy.props.EnumProperty(
name="Owner Status",
items=(
('LOCAL', "Local Task Layers", "Only objects that already have assignment"),
(
'ALL',
"All Task Layers",
"Set Ownership on any objects, even without an owner",
),
),
)
data_type: bpy.props.EnumProperty(
name="Type",
items=(
('OBJECT', "Object", "Update Owner of Objects"),
(
'TRANSFER_DATA',
"Transfer Data",
"Update Owner of Transfer Data with Objects",
),
),
)
transfer_data_type: bpy.props.EnumProperty(
name="Type Filter", items=constants.TRANSFER_DATA_TYPES_ENUM_ITEMS
)
owner_selection: bpy.props.StringProperty(name="Set Owner")
surrender_selection: bpy.props.BoolProperty(name="Set Surrender", default=False)
def _filter_by_name(self, context, unfiltered_list: []):
if self.name_filter == "":
return unfiltered_list
return [item for item in unfiltered_list if self.name_filter in item.name]
def _get_transfer_data_to_update(self, context, objs):
transfer_data_items_to_update = []
if self.data_type == "TRANSFER_DATA":
for obj in objs:
filtered_transfer_data = self._filter_by_name(
context, obj.transfer_data_ownership
)
for transfer_data_item in filtered_transfer_data:
if self.transfer_data_type != "NONE":
if transfer_data_item.type == self.transfer_data_type:
transfer_data_items_to_update.append(transfer_data_item)
else:
transfer_data_items_to_update.append(transfer_data_item)
return transfer_data_items_to_update
def _get_object_to_update(self, context):
objs = (
context.selected_objects
if self.data_source == "SELECT"
else context.scene.objects
)
if self.data_status == "OWNED":
return [
item
for item in self._filter_by_name(context, objs)
if item.asset_id_owner != "NONE"
]
return self._filter_by_name(context, objs)
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
# if self.owner_selection == "NONE":
# self.owner_selection = get_local_task_layers()[0]
return context.window_manager.invoke_props_dialog(self, width=400)
def draw(self, context: bpy.types.Context):
layout = self.layout
split = layout.split(align=True)
layout.row(align=True).prop(self, "data_source", expand=True)
layout.prop(self, "data_type", text="Update Owner of")
if self.data_type == "OBJECT":
box = layout.box()
box.prop(self, "data_status")
if self.data_type == "TRANSFER_DATA":
box = layout.box()
box.prop(self, "transfer_data_type")
box.prop(self, "owner_filter", text="Owner Filter")
box.prop(self, "name_filter", text="Name Filter")
if self.owner_filter == "LOCAL":
show_local = True
show_all_task_layers = False
else:
show_local = False
show_all_task_layers = True
draw_task_layer_selection(
box,
context.scene,
self,
self.owner_selection,
'owner_selection',
show_all_task_layers=show_all_task_layers,
show_local=show_local,
text="Set Owner",
)
# TODO Logically this can't be assigned to all objects, only ones I Own?
# if self.data_type == "TRANSFER_DATA":
# box.prop(self, "surrender_selection", expand=True)
objs = self._get_object_to_update(context)
if self.data_type == "OBJECT":
data_type_name = "Object(s)"
length = len(objs) if objs else 0
else:
transfer_data_items_to_update = self._get_transfer_data_to_update(
context, objs
)
data_type_name = "Transfer Data Item(s)"
length = (
len(transfer_data_items_to_update)
if transfer_data_items_to_update
else 0
)
layout.label(text=f"Change Ownership on {length} {data_type_name}")
def execute(self, context: bpy.types.Context):
objs = self._get_object_to_update(context)
if self.data_type == "OBJECT":
for obj in objs:
obj.asset_id_owner = self.owner_selection
else:
transfer_data_items_to_update = self._get_transfer_data_to_update(
context, objs
)
for transfer_data_item_to_update in transfer_data_items_to_update:
transfer_data_item_to_update.owner = self.owner_selection
# if self.surrender_selection:
# transfer_data_item_to_update.surrender = True
return {'FINISHED'}
classes = (
ASSETPIPE_OT_update_ownership,
ASSETPIPE_OT_sync_push,
@ -517,6 +691,7 @@ classes = (
ASSETPIPE_OT_revert_file,
ASSETPIPE_OT_fix_prefixes,
ASSETPIPE_OT_update_surrendered_transfer_data,
ASSETPIPE_OT_batch_ownership_change,
)

View File

@ -79,6 +79,7 @@ class ASSETPIPE_PT_sync_advanced(bpy.types.Panel):
box = layout.box()
box.operator("assetpipe.reset_ownership", icon="LOOP_BACK")
box.operator("assetpipe.fix_prefixes", icon="CHECKMARK")
box.operator("assetpipe.batch_ownership_change")
box.operator("assetpipe.revert_file", icon="FILE_TICK")
# Task Layer Updater