From 602faa81dc75323cc34797ea1e4de5aab0b2e778 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 18 Feb 2025 17:41:52 +0100 Subject: [PATCH] Add Task Types profiles filtering for defaults (note that it uses current context, not the task type from the instance) --- .../publish/extract_usd_layer_contributions.py | 4 +++- server/settings/publish_plugins.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py b/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py index bf4ca70afa..a2698b03de 100644 --- a/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py +++ b/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py @@ -470,8 +470,10 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin, return [] # Set default target layer based on product type + current_context_task_type = create_context.get_current_task_type() profile = filter_profiles(cls.profiles, { - "product_types": instance.data["productType"] + "product_types": instance.data["productType"], + "task_types": current_context_task_type }) if not profile: profile = {} diff --git a/server/settings/publish_plugins.py b/server/settings/publish_plugins.py index 462b1e2861..d10a6b7507 100644 --- a/server/settings/publish_plugins.py +++ b/server/settings/publish_plugins.py @@ -79,6 +79,17 @@ class CollectUSDLayerContributionsProfileModel(BaseSettingsModel): " settings below would apply to the instance as default" " attributes." ), + section="Filter" + ) + task_types: list[str] = SettingsField( + default_factory=list, + title="Task Types", + enum_resolver=task_types_enum, + description=( + "The current create context task type to filter against. This" + " allows to filter the profile to only be valid if currently " + " creating from within that task type." + ), ) contribution_layer: str = SettingsField( "", @@ -88,6 +99,7 @@ class CollectUSDLayerContributionsProfileModel(BaseSettingsModel): " matching this profile. The layer name should be in the" " 'Department Layer Orders' list to get a sensible order." ), + section="Instance attribute defaults", ) contribution_apply_as_variant: bool = SettingsField( True, @@ -1069,30 +1081,35 @@ DEFAULT_PUBLISH_VALUES = { "profiles": [ { "product_types": ["model"], + "task_types": [], "contribution_layer": "model", "contribution_apply_as_variant": True, "contribution_target_product": "usdAsset" }, { "product_types": ["look"], + "task_types": [], "contribution_layer": "look", "contribution_apply_as_variant": True, "contribution_target_product": "usdAsset" }, { "product_types": ["groom"], + "task_types": [], "contribution_layer": "groom", "contribution_apply_as_variant": True, "contribution_target_product": "usdAsset" }, { "product_types": ["rig"], + "task_types": [], "contribution_layer": "rig", "contribution_apply_as_variant": True, "contribution_target_product": "usdAsset" }, { "product_types": ["usd"], + "task_types": [], "contribution_layer": "assembly", "contribution_apply_as_variant": False, "contribution_target_product": "usdShot"