diff --git a/client/ayon_blender/api/pipeline.py b/client/ayon_blender/api/pipeline.py index 71d5f13..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 @@ -273,6 +274,24 @@ def set_frame_range(entity: dict): if attrib.get("fps"): fps = attrib.get("fps") + # Should handles be included, defined by settings + settings = get_project_settings(get_current_project_name()) + task_type = entity.get("taskType") + include_handles_settings = settings["blender"]["include_handles"] + include_handles = include_handles_settings["include_handles_default"] + 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)) + scene.frame_start = frame_start scene.frame_end = frame_end scene.render.fps = round(fps) diff --git a/server/settings/main.py b/server/settings/main.py index 3cca22a..02b9a2a 100644 --- a/server/settings/main.py +++ b/server/settings/main.py @@ -2,8 +2,8 @@ BaseSettingsModel, SettingsField, TemplateWorkfileBaseOptions, + task_types_enum, ) - from .imageio import BlenderImageIOModel from .publish_plugins import ( PublishPluginsModel, @@ -24,6 +24,31 @@ class UnitScaleSettingsModel(BaseSettingsModel): ) +class IncludeHandlesProfilesModel(BaseSettingsModel): + task_types: list[str] = SettingsField( + default_factory=list, + 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") + + +class IncludeHandlesModel(BaseSettingsModel): + include_handles_default: bool = SettingsField( + False, title="Include handles by default" + ) + profiles: list[IncludeHandlesProfilesModel] = SettingsField( + default_factory=list, + title="Include/exclude handles by profiles" + ) + + class BlenderSettings(BaseSettingsModel): unit_scale_settings: UnitScaleSettingsModel = SettingsField( default_factory=UnitScaleSettingsModel, @@ -37,6 +62,10 @@ class BlenderSettings(BaseSettingsModel): True, title="Set Start/End Frames and FPS on Startup" ) + include_handles: IncludeHandlesModel = SettingsField( + default_factory=IncludeHandlesModel, + title="Include/Exclude Handles in default playback & render range" + ) imageio: BlenderImageIOModel = SettingsField( default_factory=BlenderImageIOModel, title="Color Management (ImageIO)" @@ -61,6 +90,10 @@ class BlenderSettings(BaseSettingsModel): }, "set_frames_startup": True, "set_resolution_startup": True, + "include_handles": { + "include_handles_default": False, + "profiles": [] + }, "RenderSettings": DEFAULT_RENDER_SETTINGS, "publish": DEFAULT_BLENDER_PUBLISH_SETTINGS, "workfile_builder": {