Blender Kitsu: Add option to Exclude Collections from Output Collection #120
@ -399,7 +399,7 @@ class KITSU_OT_unlink_collection_with_string(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class KITSU_PG_exclude_collection(bpy.types.PropertyGroup):
|
class KITSU_PG_anim_exclude_coll(bpy.types.PropertyGroup):
|
||||||
exclude: bpy.props.BoolProperty(
|
exclude: bpy.props.BoolProperty(
|
||||||
name="Exclude",
|
name="Exclude",
|
||||||
description="",
|
description="",
|
||||||
@ -415,8 +415,6 @@ class KITSU_OT_anim_update_output_coll(bpy.types.Operator):
|
|||||||
bl_description = (
|
bl_description = (
|
||||||
"Scans scene for any collections that are not yet in the output collection"
|
"Scans scene for any collections that are not yet in the output collection"
|
||||||
)
|
)
|
||||||
active_shot = None
|
|
||||||
output_coll_name = None
|
|
||||||
output_coll = None
|
output_coll = None
|
||||||
asset_colls = 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)
|
return bool(active_shot and output_coll)
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
self.active_shot = cache.shot_active_get()
|
active_shot = cache.shot_active_get()
|
||||||
self.output_coll_name = opsdata.get_output_coll_name(self.active_shot)
|
output_coll_name = opsdata.get_output_coll_name(active_shot)
|
||||||
self.output_coll = bpy.data.collections[self.output_coll_name]
|
self.output_coll = bpy.data.collections[output_coll_name]
|
||||||
return context.window_manager.invoke_props_dialog(self, width=500)
|
return context.window_manager.invoke_props_dialog(self, width=500)
|
||||||
|
|
||||||
def get_collections(self, context):
|
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")
|
box.label(text="Select Collection to Exclude", icon="OUTLINER_COLLECTION")
|
||||||
column = box.column(align=True)
|
column = box.column(align=True)
|
||||||
for col in parents:
|
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]:
|
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||||
# Clear Out Output Collection before Starting
|
# 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)
|
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)
|
||||||
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:
|
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)
|
||||||
@ -497,19 +495,19 @@ classes = [
|
|||||||
KITSU_OT_anim_update_output_coll,
|
KITSU_OT_anim_update_output_coll,
|
||||||
KITSU_OT_anim_enforce_naming_convention,
|
KITSU_OT_anim_enforce_naming_convention,
|
||||||
KITSU_OT_unlink_collection_with_string,
|
KITSU_OT_unlink_collection_with_string,
|
||||||
KITSU_PG_exclude_collection,
|
KITSU_PG_anim_exclude_coll,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
bpy.utils.register_class(cls)
|
bpy.utils.register_class(cls)
|
||||||
bpy.types.Collection.blender_kitsu_exclusions = bpy.props.PointerProperty(
|
bpy.types.Collection.anim_output = bpy.props.PointerProperty(
|
||||||
type=KITSU_PG_exclude_collection
|
type=KITSU_PG_anim_exclude_coll
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
bpy.utils.unregister_class(cls)
|
bpy.utils.unregister_class(cls)
|
||||||
del bpy.types.Collection.blender_kitsu_exclusions
|
del bpy.types.Collection.anim_output
|
||||||
|
Loading…
Reference in New Issue
Block a user