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.
Showing only changes of commit c35cee9e87 - Show all commits

View File

@ -345,7 +345,7 @@ class ASSETPIPE_OT_reset_ownership(bpy.types.Operator):
bl_description = ( bl_description = (
"""Reset the Object owner and transfer data on selected object(s)""" """Reset the Object owner and transfer data on selected object(s)"""
) )
@classmethod @classmethod
def poll(cls, context: bpy.types.Context) -> bool: def poll(cls, context: bpy.types.Context) -> bool:
if len(context.selected_objects) == 0: if len(context.selected_objects) == 0:
@ -407,8 +407,10 @@ class ASSETPIPE_OT_update_local_task_layers(bpy.types.Operator):
class ASSETPIPE_OT_revert_file(bpy.types.Operator): class ASSETPIPE_OT_revert_file(bpy.types.Operator):
bl_idname = "assetpipe.revert_file" bl_idname = "assetpipe.revert_file"
bl_label = "Revert File" bl_label = "Revert File"
bl_description = """Revert File to Pre-Sync State. Revert will not affect Published files""" bl_description = (
"""Revert File to Pre-Sync State. Revert will not affect Published files"""
)
_temp_file = "" _temp_file = ""
_source_file = "" _source_file = ""
@ -416,61 +418,65 @@ class ASSETPIPE_OT_revert_file(bpy.types.Operator):
asset_pipe = context.scene.asset_pipeline asset_pipe = context.scene.asset_pipeline
self._temp_file = asset_pipe.temp_file self._temp_file = asset_pipe.temp_file
self._source_file = asset_pipe.source_file self._source_file = asset_pipe.source_file
# TODO Add Error Messages if path is empty # TODO Add Error Messages if path is empty
bpy.ops.wm.open_mainfile(filepath=self._temp_file) bpy.ops.wm.open_mainfile(filepath=self._temp_file)
bpy.ops.wm.save_as_mainfile(filepath=self._source_file) bpy.ops.wm.save_as_mainfile(filepath=self._source_file)
return {'FINISHED'} return {'FINISHED'}
class ASSETPIPE_OT_fix_prefixes(bpy.types.Operator): class ASSETPIPE_OT_fix_prefixes(bpy.types.Operator):
bl_idname = "assetpipe.fix_prefixes" bl_idname = "assetpipe.fix_prefixes"
bl_label = "Fix Prefixes" bl_label = "Fix Prefixes"
bl_description = """Fix Prefixes for Modifiers and Constraints so they match Transfer Data Owner on selected object(s)""" bl_description = """Fix Prefixes for Modifiers and Constraints so they match Transfer Data Owner on selected object(s)"""
_updated_prefix = False _updated_prefix = False
@classmethod @classmethod
def poll(cls, context: bpy.types.Context) -> bool: def poll(cls, context: bpy.types.Context) -> bool:
if len(context.selected_objects) == 0: if len(context.selected_objects) == 0:
cls.poll_message_set("No Objects Selected") cls.poll_message_set("No Objects Selected")
return False return False
return True return True
def transfer_data_update_prefix(self, context, transfer_data_item): def transfer_data_update_prefix(self, context, transfer_data_item):
obj = transfer_data_item.id_data obj = transfer_data_item.id_data
td_data = data_type_from_transfer_data_key(obj, transfer_data_item.type) 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) 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): )
if new_name == transfer_data_item.name or not td_data.get(
transfer_data_item.name
):
return return
td_data[transfer_data_item.name].name = new_name td_data[transfer_data_item.name].name = new_name
transfer_data_item.name = new_name transfer_data_item.name = new_name
self.report( self.report(
{'INFO'}, {'INFO'},
f"Renamed {transfer_data_item.type} on '{obj.name}' to {new_name}", f"Renamed {transfer_data_item.type} on '{obj.name}' to {new_name}",
) )
self._updated_prefix = True self._updated_prefix = True
def transfer_data_using_prefix_get(self, context, obj): def transfer_data_using_prefix_get(self, context, obj):
types_to_update = [constants.MODIFIER_KEY, constants.CONSTRAINT_KEY] 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] 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): def transfer_data_update_all_prefixes(self, context, obj):
transfer_data_items = self.transfer_data_using_prefix_get(context, obj) transfer_data_items = self.transfer_data_using_prefix_get(context, obj)
for transfer_data_item in transfer_data_items: for transfer_data_item in transfer_data_items:
self.transfer_data_update_prefix(context, transfer_data_item) self.transfer_data_update_prefix(context, transfer_data_item)
def execute(self, context: bpy.types.Context): def execute(self, context: bpy.types.Context):
objs = context.selected_objects objs = context.selected_objects
for obj in objs: for obj in objs:
self.transfer_data_update_all_prefixes(context, obj) self.transfer_data_update_all_prefixes(context, obj)
if not self._updated_prefix: if not self._updated_prefix:
self.report( self.report(
{'WARNING'}, {'WARNING'},
f"No Prefixes found to update", f"No Prefixes found to update",
) )
return {'FINISHED'} return {'FINISHED'}