From 6534f1c5f390359f36ec3ed1bb8e0b0560ce4855 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 6 Sep 2024 14:22:44 +0200 Subject: [PATCH] Use profiles instead --- client/ayon_blender/api/pipeline.py | 16 +++++++++++----- server/settings/main.py | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/client/ayon_blender/api/pipeline.py b/client/ayon_blender/api/pipeline.py index e08876f..5f81ec4 100644 --- a/client/ayon_blender/api/pipeline.py +++ b/client/ayon_blender/api/pipeline.py @@ -30,7 +30,8 @@ from ayon_core.lib import ( Logger, register_event_callback, - emit_event + emit_event, + filter_profiles ) from ayon_core.settings import get_project_settings from ayon_blender import BLENDER_ADDON_ROOT @@ -278,10 +279,15 @@ def set_frame_range(entity: dict): task_type = entity.get("taskType") include_handles_settings = settings["blender"]["include_handles"] include_handles = include_handles_settings["include_handles_default"] - for item in include_handles_settings["per_task_type"]: - if task_type in item["task_types"]: - include_handles = item["include_handles"] - break + profile = filter_profiles( + include_handles_settings["profiles"], + key_values={ + "task_types": task_type, + "task_names": entity["name"] + } + ) + if profile: + include_handles = profile["include_handles"] if include_handles: frame_start -= int(attrib.get("handleStart", 0)) frame_end += int(attrib.get("handleEnd", 0)) diff --git a/server/settings/main.py b/server/settings/main.py index 724f0a3..02b9a2a 100644 --- a/server/settings/main.py +++ b/server/settings/main.py @@ -24,11 +24,17 @@ class UnitScaleSettingsModel(BaseSettingsModel): ) -class IncludeByTaskTypeModel(BaseSettingsModel): +class IncludeHandlesProfilesModel(BaseSettingsModel): task_types: list[str] = SettingsField( default_factory=list, - title="Task types", - enum_resolver=task_types_enum + title="Task Types", + description="Filter by task types", + enum_resolver=task_types_enum, + ) + task_names: list[str] = SettingsField( + default_factory=list, + title="Task Names", + description="Filter by task names.", ) include_handles: bool = SettingsField(True, title="Include handles") @@ -37,9 +43,9 @@ class IncludeHandlesModel(BaseSettingsModel): include_handles_default: bool = SettingsField( False, title="Include handles by default" ) - per_task_type: list[IncludeByTaskTypeModel] = SettingsField( + profiles: list[IncludeHandlesProfilesModel] = SettingsField( default_factory=list, - title="Include/exclude handles by task type" + title="Include/exclude handles by profiles" ) @@ -86,7 +92,7 @@ class BlenderSettings(BaseSettingsModel): "set_resolution_startup": True, "include_handles": { "include_handles_default": False, - "per_task_type": [] + "profiles": [] }, "RenderSettings": DEFAULT_RENDER_SETTINGS, "publish": DEFAULT_BLENDER_PUBLISH_SETTINGS,