mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Move the profile defaults to settings
This commit is contained in:
parent
3105869857
commit
b9cc8c3507
2 changed files with 89 additions and 36 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from operator import attrgetter
|
||||
import dataclasses
|
||||
import os
|
||||
from typing import Dict
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import pyblish.api
|
||||
try:
|
||||
|
|
@ -282,6 +282,9 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin,
|
|||
"fx": 500,
|
||||
"lighting": 600,
|
||||
}
|
||||
# Default profiles to set certain instance attribute defaults based on
|
||||
# profiles in settings
|
||||
profiles: List[Dict[str, Any]] = []
|
||||
|
||||
@classmethod
|
||||
def apply_settings(cls, project_settings):
|
||||
|
|
@ -299,6 +302,8 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin,
|
|||
if contribution_layers:
|
||||
cls.contribution_layers = contribution_layers
|
||||
|
||||
cls.profiles = plugin_settings.get("profiles", [])
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
attr_values = self.get_attr_values_from_data(instance.data)
|
||||
|
|
@ -465,41 +470,8 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin,
|
|||
return []
|
||||
|
||||
# Set default target layer based on product type
|
||||
# TODO: Define profiles in settings
|
||||
profiles = [
|
||||
{
|
||||
"productType": "model",
|
||||
"contribution_layer": "model",
|
||||
"contribution_apply_as_variant": True,
|
||||
"contribution_target_product": "usdAsset"
|
||||
},
|
||||
{
|
||||
"productType": "look",
|
||||
"contribution_layer": "look",
|
||||
"contribution_apply_as_variant": True,
|
||||
"contribution_target_product": "usdAsset"
|
||||
},
|
||||
{
|
||||
"productType": "groom",
|
||||
"contribution_layer": "groom",
|
||||
"contribution_apply_as_variant": True,
|
||||
"contribution_target_product": "usdAsset"
|
||||
},
|
||||
{
|
||||
"productType": "rig",
|
||||
"contribution_layer": "rig",
|
||||
"contribution_apply_as_variant": True,
|
||||
"contribution_target_product": "usdShot"
|
||||
},
|
||||
{
|
||||
"productType": "usd",
|
||||
"contribution_layer": "assembly",
|
||||
"contribution_apply_as_variant": False,
|
||||
"contribution_target_product": "usdShot"
|
||||
},
|
||||
]
|
||||
profile = filter_profiles(profiles, {
|
||||
"productType": instance.data["productType"]
|
||||
profile = filter_profiles(cls.profiles, {
|
||||
"product_types": instance.data["productType"]
|
||||
})
|
||||
if not profile:
|
||||
profile = {}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,47 @@ class ContributionLayersModel(BaseSettingsModel):
|
|||
"layer on top.")
|
||||
|
||||
|
||||
class CollectUSDLayerContributionsProfileModel(BaseSettingsModel):
|
||||
"""Profiles to define instance attribute defaults for USD contribution."""
|
||||
_layout = "expanded"
|
||||
product_types: list[str] = SettingsField(
|
||||
default_factory=list,
|
||||
title="Product types",
|
||||
description=(
|
||||
"The product types to match this profile to. When matched, the"
|
||||
" settings below would apply to the instance as default"
|
||||
" attributes."
|
||||
),
|
||||
)
|
||||
contribution_layer: str = SettingsField(
|
||||
"",
|
||||
title="Contribution Department Layer",
|
||||
description=(
|
||||
"The default contribution layer to apply the contribution to when"
|
||||
" matching this profile. The layer name should be in the"
|
||||
" 'Department Layer Orders' list to get a sensible order."
|
||||
),
|
||||
)
|
||||
contribution_apply_as_variant: bool = SettingsField(
|
||||
True,
|
||||
title="Apply as variant",
|
||||
description=(
|
||||
"The default 'Apply as variant' state for instances matching this"
|
||||
" profile. Usually enabled for asset contributions and disabled"
|
||||
" for shot contributions."
|
||||
),
|
||||
)
|
||||
contribution_target_product: str = SettingsField(
|
||||
"usdAsset",
|
||||
title="Target Product",
|
||||
description=(
|
||||
"The default destination product name to apply the contribution to"
|
||||
" when matching this profile."
|
||||
" Usually e.g. 'usdAsset' or 'usdShot'."
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class CollectUSDLayerContributionsModel(BaseSettingsModel):
|
||||
enabled: bool = SettingsField(True, title="Enabled")
|
||||
contribution_layers: list[ContributionLayersModel] = SettingsField(
|
||||
|
|
@ -77,6 +118,14 @@ class CollectUSDLayerContributionsModel(BaseSettingsModel):
|
|||
"ordering inside the USD contribution workflow."
|
||||
)
|
||||
)
|
||||
profiles: list[CollectUSDLayerContributionsProfileModel] = SettingsField(
|
||||
default_factory=list,
|
||||
title="Profiles",
|
||||
description=(
|
||||
"Define attribute defaults for USD Contributions on publish"
|
||||
" instances."
|
||||
)
|
||||
)
|
||||
|
||||
@validator("contribution_layers")
|
||||
def validate_unique_outputs(cls, value):
|
||||
|
|
@ -1017,6 +1066,38 @@ DEFAULT_PUBLISH_VALUES = {
|
|||
{"name": "fx", "order": 500},
|
||||
{"name": "lighting", "order": 600},
|
||||
],
|
||||
"profiles": [
|
||||
{
|
||||
"product_types": ["model"],
|
||||
"contribution_layer": "model",
|
||||
"contribution_apply_as_variant": True,
|
||||
"contribution_target_product": "usdAsset"
|
||||
},
|
||||
{
|
||||
"product_types": ["look"],
|
||||
"contribution_layer": "look",
|
||||
"contribution_apply_as_variant": True,
|
||||
"contribution_target_product": "usdAsset"
|
||||
},
|
||||
{
|
||||
"product_types": ["groom"],
|
||||
"contribution_layer": "groom",
|
||||
"contribution_apply_as_variant": True,
|
||||
"contribution_target_product": "usdAsset"
|
||||
},
|
||||
{
|
||||
"product_types": ["rig"],
|
||||
"contribution_layer": "rig",
|
||||
"contribution_apply_as_variant": True,
|
||||
"contribution_target_product": "usdAsset"
|
||||
},
|
||||
{
|
||||
"product_types": ["usd"],
|
||||
"contribution_layer": "assembly",
|
||||
"contribution_apply_as_variant": False,
|
||||
"contribution_target_product": "usdShot"
|
||||
},
|
||||
]
|
||||
},
|
||||
"ValidateEditorialAssetName": {
|
||||
"enabled": True,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue