Blender Kitsu: Add option to Exclude Collections from Output Collection #120
@ -439,23 +439,17 @@ class KITSU_OT_anim_update_output_coll(bpy.types.Operator):
|
|||||||
|
|
||||||
def get_collections(self, context):
|
def get_collections(self, context):
|
||||||
self.asset_colls = opsdata.find_asset_collections_in_scene(context.scene)
|
self.asset_colls = opsdata.find_asset_collections_in_scene(context.scene)
|
||||||
missing: List[bpy.types.Collection] = []
|
|
||||||
|
|
||||||
# Check if all found asset colls are in output coll.
|
|
||||||
for coll in self.asset_colls:
|
|
||||||
missing.append(coll)
|
|
||||||
|
|
||||||
# Only take parent colls.
|
# Only take parent colls.
|
||||||
childs = []
|
childs = []
|
||||||
for i in range(len(missing)):
|
for i in range(len(self.asset_colls)):
|
||||||
coll = missing[i]
|
coll = self.asset_colls[i]
|
||||||
coll_childs = list(opsdata.traverse_collection_tree(coll))
|
coll_childs = list(opsdata.traverse_collection_tree(coll))
|
||||||
for j in range(i + 1, len(missing)):
|
for j in range(i + 1, len(self.asset_colls)):
|
||||||
coll_comp = missing[j]
|
coll_comp = self.asset_colls[j]
|
||||||
if coll_comp in coll_childs:
|
if coll_comp in coll_childs:
|
||||||
childs.append(coll_comp)
|
childs.append(coll_comp)
|
||||||
|
|
||||||
return [coll for coll in missing if coll not in childs]
|
return [coll for coll in self.asset_colls if coll not in childs]
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
parents = self.get_collections(context)
|
parents = self.get_collections(context)
|
||||||
@ -475,10 +469,7 @@ class KITSU_OT_anim_update_output_coll(bpy.types.Operator):
|
|||||||
self.output_coll.children.unlink(collection)
|
self.output_coll.children.unlink(collection)
|
||||||
bpy.context.view_layer.update()
|
bpy.context.view_layer.update()
|
||||||
parents = self.get_collections(context)
|
parents = self.get_collections(context)
|
||||||
if self.exclude_collections:
|
parents = [col for col in parents if not col.blender_kitsu_exclusions.exclude]
|
||||||
parents = [
|
|
||||||
col for col in parents if not col.blender_kitsu_exclusions.exclude
|
|
||||||
]
|
|
||||||
for coll in parents:
|
for coll in parents:
|
||||||
self.output_coll.children.link(coll)
|
self.output_coll.children.link(coll)
|
||||||
logger.info("%s linked in %s", coll.name, self.output_coll.name)
|
logger.info("%s linked in %s", coll.name, self.output_coll.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user