Blender Kitsu: Add option to Exclude Collections from Output Collection #120

Merged
Nick Alberelli merged 9 commits from :feature/exclude-output-collections into main 2023-07-13 19:54:03 +02:00
Showing only changes of commit ef43ae466c - Show all commits

View File

@ -399,7 +399,7 @@ class KITSU_OT_unlink_collection_with_string(bpy.types.Operator):
return {"FINISHED"}
class KITSU_PG_exclude_collection(bpy.types.PropertyGroup):
class KITSU_PG_anim_exclude_coll(bpy.types.PropertyGroup):
exclude: bpy.props.BoolProperty(
name="Exclude",
description="",
@ -415,8 +415,6 @@ class KITSU_OT_anim_update_output_coll(bpy.types.Operator):
bl_description = (
"Scans scene for any collections that are not yet in the output collection"
)
active_shot = None
output_coll_name = None
output_coll = None
asset_colls = None
@ -432,9 +430,9 @@ class KITSU_OT_anim_update_output_coll(bpy.types.Operator):
return bool(active_shot and output_coll)
def invoke(self, context, event):
self.active_shot = cache.shot_active_get()
self.output_coll_name = opsdata.get_output_coll_name(self.active_shot)
self.output_coll = bpy.data.collections[self.output_coll_name]
active_shot = cache.shot_active_get()
output_coll_name = opsdata.get_output_coll_name(active_shot)
self.output_coll = bpy.data.collections[output_coll_name]
return context.window_manager.invoke_props_dialog(self, width=500)
def get_collections(self, context):
@ -461,7 +459,7 @@ class KITSU_OT_anim_update_output_coll(bpy.types.Operator):
box.label(text="Select Collection to Exclude", icon="OUTLINER_COLLECTION")
column = box.column(align=True)
for col in parents:
column.prop(col.blender_kitsu_exclusions, "exclude", text=col.name)
column.prop(col.anim_output, "exclude", text=col.name)
def execute(self, context: bpy.types.Context) -> Set[str]:
# Clear Out Output Collection before Starting
@ -469,7 +467,7 @@ class KITSU_OT_anim_update_output_coll(bpy.types.Operator):
self.output_coll.children.unlink(collection)
bpy.context.view_layer.update()
parents = self.get_collections(context)
parents = [col for col in parents if not col.blender_kitsu_exclusions.exclude]
parents = [col for col in parents if not col.anim_output.exclude]
for coll in parents:
self.output_coll.children.link(coll)
logger.info("%s linked in %s", coll.name, self.output_coll.name)
@ -497,19 +495,19 @@ classes = [
KITSU_OT_anim_update_output_coll,
KITSU_OT_anim_enforce_naming_convention,
KITSU_OT_unlink_collection_with_string,
KITSU_PG_exclude_collection,
KITSU_PG_anim_exclude_coll,
]
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Collection.blender_kitsu_exclusions = bpy.props.PointerProperty(
type=KITSU_PG_exclude_collection
bpy.types.Collection.anim_output = bpy.props.PointerProperty(
type=KITSU_PG_anim_exclude_coll
)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
del bpy.types.Collection.blender_kitsu_exclusions
del bpy.types.Collection.anim_output