From 1531057a24c28493e41f200287c863f385d9fc59 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Wed, 10 Jun 2020 10:26:28 +0100 Subject: [PATCH] Refactoring --- pype/plugins/blender/load/load_animation.py | 14 ++++---------- pype/plugins/blender/load/load_layout.py | 10 ++++------ pype/plugins/blender/load/load_model.py | 10 ++++------ pype/plugins/blender/load/load_rig.py | 10 ++++------ 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/pype/plugins/blender/load/load_animation.py b/pype/plugins/blender/load/load_animation.py index a26f402d47..1c0e6e0906 100644 --- a/pype/plugins/blender/load/load_animation.py +++ b/pype/plugins/blender/load/load_animation.py @@ -29,7 +29,6 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader): icon = "code-fork" color = "orange" - @staticmethod def _remove(self, objects, lib_container): for obj in objects: @@ -41,7 +40,6 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader): bpy.data.collections.remove(bpy.data.collections[lib_container]) - @staticmethod def _process(self, libpath, lib_container, container_name): relative = bpy.context.preferences.filepaths.use_relative_paths @@ -131,7 +129,7 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader): container_metadata["lib_container"] = lib_container objects_list = self._process( - self, libpath, lib_container, container_name) + libpath, lib_container, container_name) # Save the list of objects in the metadata container container_metadata["objects"] = objects_list @@ -205,14 +203,10 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader): objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] - # Get the armature of the rig - armatures = [obj for obj in objects if obj.type == 'ARMATURE'] - assert(len(armatures) == 1) - - self._remove(self, objects, lib_container) + self._remove(objects, lib_container) objects_list = self._process( - self, str(libpath), lib_container, collection.name) + str(libpath), lib_container, collection.name) # Save the list of objects in the metadata container collection_metadata["objects"] = objects_list @@ -249,7 +243,7 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader): objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] - self._remove(self, objects, lib_container) + self._remove(objects, lib_container) bpy.data.collections.remove(collection) diff --git a/pype/plugins/blender/load/load_layout.py b/pype/plugins/blender/load/load_layout.py index b4e71fb183..4247d25caa 100644 --- a/pype/plugins/blender/load/load_layout.py +++ b/pype/plugins/blender/load/load_layout.py @@ -29,7 +29,6 @@ class BlendLayoutLoader(pype.hosts.blender.plugin.AssetLoader): icon = "code-fork" color = "orange" - @staticmethod def _remove(self, objects, lib_container): for obj in objects: @@ -46,7 +45,6 @@ class BlendLayoutLoader(pype.hosts.blender.plugin.AssetLoader): bpy.data.collections.remove(bpy.data.collections[lib_container]) - @staticmethod def _process(self, libpath, lib_container, container_name, actions): relative = bpy.context.preferences.filepaths.use_relative_paths @@ -136,7 +134,7 @@ class BlendLayoutLoader(pype.hosts.blender.plugin.AssetLoader): container_metadata["lib_container"] = lib_container objects_list = self._process( - self, libpath, lib_container, container_name, {}) + libpath, lib_container, container_name, {}) # Save the list of objects in the metadata container container_metadata["objects"] = objects_list @@ -218,10 +216,10 @@ class BlendLayoutLoader(pype.hosts.blender.plugin.AssetLoader): actions[obj.name] = obj.animation_data.action - self._remove(self, objects, lib_container) + self._remove(objects, lib_container) objects_list = self._process( - self, str(libpath), lib_container, collection.name, actions) + str(libpath), lib_container, collection.name, actions) # Save the list of objects in the metadata container collection_metadata["objects"] = objects_list @@ -258,7 +256,7 @@ class BlendLayoutLoader(pype.hosts.blender.plugin.AssetLoader): objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] - self._remove(self, objects, lib_container) + self._remove(objects, lib_container) bpy.data.collections.remove(collection) diff --git a/pype/plugins/blender/load/load_model.py b/pype/plugins/blender/load/load_model.py index 2abc4175c6..4a8f43cd48 100644 --- a/pype/plugins/blender/load/load_model.py +++ b/pype/plugins/blender/load/load_model.py @@ -30,7 +30,6 @@ class BlendModelLoader(pype.hosts.blender.plugin.AssetLoader): icon = "code-fork" color = "orange" - @staticmethod def _remove(self, objects, lib_container): for obj in objects: @@ -39,7 +38,6 @@ class BlendModelLoader(pype.hosts.blender.plugin.AssetLoader): bpy.data.collections.remove(bpy.data.collections[lib_container]) - @staticmethod def _process(self, libpath, lib_container, container_name): relative = bpy.context.preferences.filepaths.use_relative_paths @@ -118,7 +116,7 @@ class BlendModelLoader(pype.hosts.blender.plugin.AssetLoader): container_metadata["lib_container"] = lib_container objects_list = self._process( - self, libpath, lib_container, container_name) + libpath, lib_container, container_name) # Save the list of objects in the metadata container container_metadata["objects"] = objects_list @@ -189,10 +187,10 @@ class BlendModelLoader(pype.hosts.blender.plugin.AssetLoader): logger.info("Library already loaded, not updating...") return - self._remove(self, objects, lib_container) + self._remove(objects, lib_container) objects_list = self._process( - self, str(libpath), lib_container, collection.name) + str(libpath), lib_container, collection.name) # Save the list of objects in the metadata container collection_metadata["objects"] = objects_list @@ -226,7 +224,7 @@ class BlendModelLoader(pype.hosts.blender.plugin.AssetLoader): objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] - self._remove(self, objects, lib_container) + self._remove(objects, lib_container) bpy.data.collections.remove(collection) diff --git a/pype/plugins/blender/load/load_rig.py b/pype/plugins/blender/load/load_rig.py index 2b5d7fe0d7..3e53ff0363 100644 --- a/pype/plugins/blender/load/load_rig.py +++ b/pype/plugins/blender/load/load_rig.py @@ -30,7 +30,6 @@ class BlendRigLoader(pype.hosts.blender.plugin.AssetLoader): icon = "code-fork" color = "orange" - @staticmethod def _remove(self, objects, lib_container): for obj in objects: @@ -45,7 +44,6 @@ class BlendRigLoader(pype.hosts.blender.plugin.AssetLoader): bpy.data.collections.remove(bpy.data.collections[lib_container]) - @staticmethod def _process(self, libpath, lib_container, container_name, action): relative = bpy.context.preferences.filepaths.use_relative_paths @@ -131,7 +129,7 @@ class BlendRigLoader(pype.hosts.blender.plugin.AssetLoader): container_metadata["lib_container"] = lib_container objects_list = self._process( - self, libpath, lib_container, container_name, None) + libpath, lib_container, container_name, None) # Save the list of objects in the metadata container container_metadata["objects"] = objects_list @@ -210,10 +208,10 @@ class BlendRigLoader(pype.hosts.blender.plugin.AssetLoader): action = armatures[0].animation_data.action - self._remove(self, objects, lib_container) + self._remove(objects, lib_container) objects_list = self._process( - self, str(libpath), lib_container, collection.name, action) + str(libpath), lib_container, collection.name, action) # Save the list of objects in the metadata container collection_metadata["objects"] = objects_list @@ -250,7 +248,7 @@ class BlendRigLoader(pype.hosts.blender.plugin.AssetLoader): objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] - self._remove(self, objects, lib_container) + self._remove(objects, lib_container) bpy.data.collections.remove(collection)