Merge pull request #347 from simonebarbieri/bugfix/blender_crash_with_remove

Bugfix/Blender crash with remove
This commit is contained in:
Milan Kolar 2020-07-14 16:11:49 +02:00 committed by GitHub
commit 19dadf5b0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 23 deletions

View file

@ -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)

View file

@ -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':

View file

@ -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])

View file

@ -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':

View file

@ -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)

View file

@ -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':