From b4a12efecd0e65a3cd0d65e4427568a34219d4c0 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Fri, 10 Jul 2020 12:52:17 +0100 Subject: [PATCH] Fixed the crash for all loaders --- pype/plugins/blender/load/load_action.py | 16 ++-------------- pype/plugins/blender/load/load_animation.py | 4 +--- pype/plugins/blender/load/load_camera.py | 3 +-- pype/plugins/blender/load/load_layout.py | 2 +- pype/plugins/blender/load/load_model.py | 4 ++-- pype/plugins/blender/load/load_rig.py | 2 +- 6 files changed, 8 insertions(+), 23 deletions(-) diff --git a/pype/plugins/blender/load/load_action.py b/pype/plugins/blender/load/load_action.py index d94bd9aac6..1f2a870640 100644 --- a/pype/plugins/blender/load/load_action.py +++ b/pype/plugins/blender/load/load_action.py @@ -174,22 +174,16 @@ class BlendActionLoader(pype.hosts.blender.plugin.AssetLoader): strips = [] - for obj in collection_metadata["objects"]: - + for obj in list(collection_metadata["objects"]): # Get all the strips that use the action arm_objs = [ arm for arm in bpy.data.objects if arm.type == 'ARMATURE'] for armature_obj in arm_objs: - if armature_obj.animation_data is not None: - for track in armature_obj.animation_data.nla_tracks: - for strip in track.strips: - if strip.action == obj.animation_data.action: - strips.append(strip) bpy.data.actions.remove(obj.animation_data.action) @@ -277,22 +271,16 @@ class BlendActionLoader(pype.hosts.blender.plugin.AssetLoader): objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] - for obj in objects: - + for obj in list(objects): # Get all the strips that use the action arm_objs = [ arm for arm in bpy.data.objects if arm.type == 'ARMATURE'] for armature_obj in arm_objs: - if armature_obj.animation_data is not None: - for track in armature_obj.animation_data.nla_tracks: - for strip in track.strips: - if strip.action == obj.animation_data.action: - track.strips.remove(strip) bpy.data.actions.remove(obj.animation_data.action) diff --git a/pype/plugins/blender/load/load_animation.py b/pype/plugins/blender/load/load_animation.py index 1c0e6e0906..32050eca99 100644 --- a/pype/plugins/blender/load/load_animation.py +++ b/pype/plugins/blender/load/load_animation.py @@ -30,9 +30,7 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader): color = "orange" def _remove(self, objects, lib_container): - - for obj in objects: - + for obj in list(objects): if obj.type == 'ARMATURE': bpy.data.armatures.remove(obj.data) elif obj.type == 'MESH': diff --git a/pype/plugins/blender/load/load_camera.py b/pype/plugins/blender/load/load_camera.py index 7fd8f94b4e..9dd5c2bfd8 100644 --- a/pype/plugins/blender/load/load_camera.py +++ b/pype/plugins/blender/load/load_camera.py @@ -28,8 +28,7 @@ class BlendCameraLoader(pype.hosts.blender.plugin.AssetLoader): color = "orange" def _remove(self, objects, lib_container): - - for obj in objects: + for obj in list(objects): bpy.data.cameras.remove(obj.data) bpy.data.collections.remove(bpy.data.collections[lib_container]) diff --git a/pype/plugins/blender/load/load_layout.py b/pype/plugins/blender/load/load_layout.py index cfab5a207b..6a51d7cf16 100644 --- a/pype/plugins/blender/load/load_layout.py +++ b/pype/plugins/blender/load/load_layout.py @@ -21,7 +21,7 @@ class BlendLayoutLoader(plugin.AssetLoader): color = "orange" def _remove(self, objects, obj_container): - for obj in objects: + for obj in list(objects): if obj.type == 'ARMATURE': bpy.data.armatures.remove(obj.data) elif obj.type == 'MESH': diff --git a/pype/plugins/blender/load/load_model.py b/pype/plugins/blender/load/load_model.py index ad9137a15d..4ac86b3aef 100644 --- a/pype/plugins/blender/load/load_model.py +++ b/pype/plugins/blender/load/load_model.py @@ -25,8 +25,8 @@ class BlendModelLoader(plugin.AssetLoader): color = "orange" def _remove(self, objects, container): - for obj in objects: - for material_slot in obj.material_slots: + for obj in list(objects): + for material_slot in list(obj.material_slots): bpy.data.materials.remove(material_slot.material) bpy.data.meshes.remove(obj.data) diff --git a/pype/plugins/blender/load/load_rig.py b/pype/plugins/blender/load/load_rig.py index e09a9cb92f..6dc2273c6e 100644 --- a/pype/plugins/blender/load/load_rig.py +++ b/pype/plugins/blender/load/load_rig.py @@ -25,7 +25,7 @@ class BlendRigLoader(plugin.AssetLoader): color = "orange" def _remove(self, objects, obj_container): - for obj in objects: + for obj in list(objects): if obj.type == 'ARMATURE': bpy.data.armatures.remove(obj.data) elif obj.type == 'MESH':