Add Task Types profiles filtering for defaults (note that it uses current context, not the task type from the instance)

This commit is contained in:
Roy Nieterau 2025-02-18 17:41:52 +01:00
parent b9cc8c3507
commit 602faa81dc
2 changed files with 20 additions and 1 deletions

View file

@ -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 = {}

View file

@ -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"