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 56 additions and 1 deletions
Showing only changes of commit 891d61e056 - Show all commits

View File

@ -3,6 +3,8 @@ from . import config
import os
from pathlib import Path
from .merge.task_layer import set_local_task_layers
from .merge.naming import get_name_with_task_layer_prefix
from .merge.transfer_data.transfer_core import data_type_from_transfer_data_key
from .merge.publish import get_next_published_file, find_all_published
from .images import save_images
from . import constants
@ -419,6 +421,58 @@ class ASSETPIPE_OT_revert_file(bpy.types.Operator):
bpy.ops.wm.save_as_mainfile(filepath=self._source_file)
return {'FINISHED'}
class ASSETPIPE_OT_fix_prefixes(bpy.types.Operator):
bl_idname = "assetpipe.fix_prefixes"
bl_label = "Fix Prefixes"
bl_description = """Fix Prefixes for Modifiers and Constraints so they match Transfer Data Owner on selected object(s)"""
_updated_prefix = False
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
if len(context.selected_objects) == 0:
cls.poll_message_set("No Objects Selected")
return False
return True
def transfer_data_update_prefix(self, context, transfer_data_item):
obj = transfer_data_item.id_data
td_data = data_type_from_transfer_data_key(obj, transfer_data_item.type)
new_name = get_name_with_task_layer_prefix(transfer_data_item.name, transfer_data_item.owner)
if new_name == transfer_data_item.name or not td_data.get(transfer_data_item.name):
return
td_data[transfer_data_item.name].name = new_name
transfer_data_item.name = new_name
self.report(
{'INFO'},
f"Renamed {transfer_data_item.type} on '{obj.name}' to {new_name}",
)
self._updated_prefix = True
def transfer_data_using_prefix_get(self, context, obj):
types_to_update = [constants.MODIFIER_KEY, constants.CONSTRAINT_KEY]
return [td for td in obj.transfer_data_ownership if td.type in types_to_update]
def transfer_data_update_all_prefixes(self, context, obj):
transfer_data_items = self.transfer_data_using_prefix_get(context, obj)
for transfer_data_item in transfer_data_items:
self.transfer_data_update_prefix(context, transfer_data_item)
def execute(self, context: bpy.types.Context):
objs = context.selected_objects
for obj in objs:
self.transfer_data_update_all_prefixes(context, obj)
if not self._updated_prefix:
self.report(
{'WARNING'},
f"No Prefixes found to update",
)
return {'FINISHED'}
classes = (
ASSETPIPE_OT_update_ownership,
@ -429,6 +483,7 @@ classes = (
ASSETPIPE_OT_reset_ownership,
ASSETPIPE_OT_update_local_task_layers,
ASSETPIPE_OT_revert_file,
ASSETPIPE_OT_fix_prefixes,
)

View File

@ -78,9 +78,9 @@ class ASSETPIPE_PT_sync_advanced(bpy.types.Panel):
layout = self.layout
box = layout.box()
box.operator("assetpipe.reset_ownership", icon="LOOP_BACK")
box.operator("assetpipe.fix_prefixes", icon="CHECKMARK")
box.operator("assetpipe.revert_file", icon="FILE_TICK")
# Task Layer Updater
box = layout.box()
box.label(text="Change Local Task Layers")