mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
OP-3283 - implemented proper usage of {layer} in subset template for legacy creator
{layer} placeholder could be used in project_settings/global/tools/creator/subset_name_profiles to drive lower/upper cases when layer is used in subset name (eg. when multiple subsets are created at once).
Warning {layer} means keep layer name as it is, not lowercasing!
This commit is contained in:
parent
792c10cc40
commit
4379dc019e
1 changed files with 48 additions and 1 deletions
|
|
@ -1,6 +1,11 @@
|
||||||
from Qt import QtWidgets
|
from Qt import QtWidgets
|
||||||
from openpype.pipeline import create
|
from openpype.pipeline import create
|
||||||
from openpype.hosts.photoshop import api as photoshop
|
from openpype.hosts.photoshop import api as photoshop
|
||||||
|
from openpype.pipeline import legacy_io
|
||||||
|
from openpype.client import get_asset_by_name
|
||||||
|
from openpype.settings import get_project_settings
|
||||||
|
from openpype.lib import prepare_template_data
|
||||||
|
from openpype.lib.profiles_filtering import filter_profiles
|
||||||
|
|
||||||
|
|
||||||
class CreateImage(create.LegacyCreator):
|
class CreateImage(create.LegacyCreator):
|
||||||
|
|
@ -82,7 +87,18 @@ class CreateImage(create.LegacyCreator):
|
||||||
|
|
||||||
subset_name = creator_subset_name
|
subset_name = creator_subset_name
|
||||||
if len(groups) > 1:
|
if len(groups) > 1:
|
||||||
subset_name += group.name.title().replace(" ", "")
|
subset_template = self._get_subset_template(self.family)
|
||||||
|
if not subset_template or 'layer' not in subset_template.lower():
|
||||||
|
subset_name += group.name.title().replace(" ", "")
|
||||||
|
else:
|
||||||
|
fill_pairs = {
|
||||||
|
"variant": self.data["variant"],
|
||||||
|
"family": self.family,
|
||||||
|
"task": legacy_io.Session["AVALON_TASK"],
|
||||||
|
"layer": group.name
|
||||||
|
}
|
||||||
|
|
||||||
|
subset_name = subset_template.format(**prepare_template_data(fill_pairs))
|
||||||
|
|
||||||
if group.long_name:
|
if group.long_name:
|
||||||
for directory in group.long_name[::-1]:
|
for directory in group.long_name[::-1]:
|
||||||
|
|
@ -98,3 +114,34 @@ class CreateImage(create.LegacyCreator):
|
||||||
# reusing existing group, need to rename afterwards
|
# reusing existing group, need to rename afterwards
|
||||||
if not create_group:
|
if not create_group:
|
||||||
stub.rename_layer(group.id, stub.PUBLISH_ICON + group.name)
|
stub.rename_layer(group.id, stub.PUBLISH_ICON + group.name)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_dynamic_data(
|
||||||
|
cls, variant, task_name, asset_id, project_name, host_name
|
||||||
|
):
|
||||||
|
return {"layer": ""}
|
||||||
|
|
||||||
|
def _get_subset_template(self, family):
|
||||||
|
project_name = legacy_io.Session["AVALON_PROJECT"]
|
||||||
|
asset_name = legacy_io.Session["AVALON_ASSET"]
|
||||||
|
task_name = legacy_io.Session["AVALON_TASK"]
|
||||||
|
|
||||||
|
asset_doc = get_asset_by_name(
|
||||||
|
project_name, asset_name, fields=["data.tasks"]
|
||||||
|
)
|
||||||
|
asset_tasks = asset_doc.get("data", {}).get("tasks") or {}
|
||||||
|
task_info = asset_tasks.get(task_name) or {}
|
||||||
|
task_type = task_info.get("type")
|
||||||
|
|
||||||
|
tools_settings = get_project_settings(project_name)["global"]["tools"]
|
||||||
|
profiles = tools_settings["creator"]["subset_name_profiles"]
|
||||||
|
filtering_criteria = {
|
||||||
|
"families": family,
|
||||||
|
"hosts": "photoshop",
|
||||||
|
"tasks": task_name,
|
||||||
|
"task_types": task_type
|
||||||
|
}
|
||||||
|
|
||||||
|
matching_profile = filter_profiles(profiles, filtering_criteria)
|
||||||
|
if matching_profile:
|
||||||
|
return matching_profile["template"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue