Code improvements from suggestions

Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
This commit is contained in:
Simone Barbieri 2023-10-19 11:18:59 +01:00
parent 2517408919
commit 4418d11164
2 changed files with 8 additions and 15 deletions

View file

@ -60,19 +60,14 @@ class CacheModelLoader(plugin.AssetLoader):
imported = lib.get_selection()
empties = [obj for obj in imported if obj.type == 'EMPTY']
container = None
for empty in empties:
if not empty.parent:
container = empty
break
# Use first EMPTY without parent as container
container = next(
(obj for obj in imported if obj.type == "EMPTY" and not obj.parent),
None
)
objects = []
if container:
# Children must be linked before parents,
# otherwise the hierarchy will break
nodes = list(container.children)
for obj in nodes:
@ -80,11 +75,9 @@ class CacheModelLoader(plugin.AssetLoader):
bpy.data.objects.remove(container)
objects.extend(nodes)
for obj in nodes:
objects.append(obj)
objects.extend(list(obj.children_recursive))
objects.reverse()
objects.extend(obj.children_recursive)
else:
for obj in imported:
obj.parent = asset_group

View file

@ -51,7 +51,7 @@ class CollectInstances(pyblish.api.ContextPlugin):
for group in asset_groups:
instance = self.create_instance(context, group)
members = []
if type(group) == bpy.types.Collection:
if isinstance(group, bpy.types.Collection):
members = list(group.objects)
family = instance.data["family"]
if family == "animation":