From 651eb594c8f07d8d16f01f592bed8ea5a2892d74 Mon Sep 17 00:00:00 2001 From: Tony Dorfmeister Date: Wed, 25 Jun 2025 13:25:50 +0200 Subject: [PATCH 1/4] adds server settings from BigRoy:enhancement/maya_template_workfile_build_settings_create_first_version --- server/settings/templated_workfile_settings.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/settings/templated_workfile_settings.py b/server/settings/templated_workfile_settings.py index 1baa2c89..e7025471 100644 --- a/server/settings/templated_workfile_settings.py +++ b/server/settings/templated_workfile_settings.py @@ -16,6 +16,13 @@ class WorkfileBuildProfilesModel(BaseSettingsModel): default_factory=list, title="Task names" ) path: str = SettingsField("", title="Path to template") + keep_placeholder: bool = SettingsField( + False, + title="Keep placeholders") + create_first_version: bool = SettingsField( + True, + title="Create first version" + ) class TemplatedProfilesModel(BaseSettingsModel): From fc194e831c1fbf80d470993242e83383c18563e3 Mon Sep 17 00:00:00 2001 From: Tony Dorfmeister Date: Wed, 25 Jun 2025 13:26:28 +0200 Subject: [PATCH 2/4] calls build_template on new file created --- client/ayon_maya/api/pipeline.py | 4 +++- client/ayon_maya/api/workfile_template_builder.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/ayon_maya/api/pipeline.py b/client/ayon_maya/api/pipeline.py index 9d5816b5..8afffe5b 100644 --- a/client/ayon_maya/api/pipeline.py +++ b/client/ayon_maya/api/pipeline.py @@ -48,7 +48,7 @@ from ayon_maya import MAYA_ROOT_DIR from ayon_maya.lib import create_workspace_mel -from . import menu, lib +from . import menu, lib, workfile_template_builder from .workio import ( open_file, save_file, @@ -661,6 +661,8 @@ def on_new(): with lib.suspended_refresh(): lib.set_context_settings() + workfile_template_builder.build_workfile_template( + workfile_creation_enabled=True) _remove_workfile_lock() diff --git a/client/ayon_maya/api/workfile_template_builder.py b/client/ayon_maya/api/workfile_template_builder.py index f4f9a349..dac8452d 100644 --- a/client/ayon_maya/api/workfile_template_builder.py +++ b/client/ayon_maya/api/workfile_template_builder.py @@ -246,9 +246,9 @@ def read(self, node): return data -def build_workfile_template(*args): +def build_workfile_template(*args, **kwargs): builder = MayaTemplateBuilder(registered_host()) - builder.build_template() + builder.build_template(*args, **kwargs) def update_workfile_template(*args): From 14220314b398031ffeacbe9ae1f3559d2fb760b4 Mon Sep 17 00:00:00 2001 From: Tony Dorfmeister Date: Tue, 8 Jul 2025 12:06:54 +0200 Subject: [PATCH 3/4] wraps temoplate builder in try/catch --- client/ayon_maya/api/pipeline.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/ayon_maya/api/pipeline.py b/client/ayon_maya/api/pipeline.py index 8afffe5b..0cdfc880 100644 --- a/client/ayon_maya/api/pipeline.py +++ b/client/ayon_maya/api/pipeline.py @@ -45,6 +45,10 @@ is_workfile_locked, is_workfile_lock_enabled ) +from ayon_core.pipeline.workfile.workfile_template_builder import ( + TemplateProfileNotFound +) + from ayon_maya import MAYA_ROOT_DIR from ayon_maya.lib import create_workspace_mel @@ -661,8 +665,14 @@ def on_new(): with lib.suspended_refresh(): lib.set_context_settings() - workfile_template_builder.build_workfile_template( - workfile_creation_enabled=True) + try: + workfile_template_builder.build_workfile_template( + workfile_creation_enabled=True) + except TemplateProfileNotFound: + log.debug( + "No workfile template profile enabled for current context. " + "Skipping workfile creation." + ) _remove_workfile_lock() From 684f7fc3bddf6536f6b5d34bc305a9c2324f83d9 Mon Sep 17 00:00:00 2001 From: Tony Dorfmeister Date: Fri, 11 Jul 2025 16:52:31 +0200 Subject: [PATCH 4/4] refactors template build from on_new callback to userSetup --- client/ayon_maya/api/pipeline.py | 13 +------------ client/ayon_maya/startup/userSetup.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/client/ayon_maya/api/pipeline.py b/client/ayon_maya/api/pipeline.py index f496c0ac..5b34a40a 100644 --- a/client/ayon_maya/api/pipeline.py +++ b/client/ayon_maya/api/pipeline.py @@ -45,14 +45,11 @@ is_workfile_locked, is_workfile_lock_enabled ) -from ayon_core.pipeline.workfile.workfile_template_builder import ( - TemplateProfileNotFound -) from ayon_maya import MAYA_ROOT_DIR from ayon_maya.lib import create_workspace_mel -from . import menu, lib, workfile_template_builder +from . import menu, lib from .workio import ( open_file, save_file, @@ -666,14 +663,6 @@ def on_new(): with lib.suspended_refresh(): lib.set_context_settings() - try: - workfile_template_builder.build_workfile_template( - workfile_creation_enabled=True) - except TemplateProfileNotFound: - log.debug( - "No workfile template profile enabled for current context. " - "Skipping workfile creation." - ) _remove_workfile_lock() diff --git a/client/ayon_maya/startup/userSetup.py b/client/ayon_maya/startup/userSetup.py index 600864fd..bc6b1abe 100644 --- a/client/ayon_maya/startup/userSetup.py +++ b/client/ayon_maya/startup/userSetup.py @@ -2,7 +2,10 @@ from ayon_core.settings import get_project_settings from ayon_core.pipeline import install_host, get_current_project_name -from ayon_maya.api import MayaHost +from ayon_maya.api import MayaHost, workfile_template_builder +from ayon_core.pipeline.workfile.workfile_template_builder import ( + TemplateProfileNotFound +) from maya import cmds @@ -39,8 +42,19 @@ def _explicit_load_plugins(): if bool(int(os.environ.get(key, "0"))): def _log_and_open(): path = os.environ["AYON_LAST_WORKFILE"] - print("Opening \"{}\"".format(path)) - cmds.file(path, open=True, force=True) + if os.path.exists(path): + print("Opening \"{}\"".format(path)) + cmds.file(path, open=True, force=True) + else: + try: + workfile_template_builder.build_workfile_template( + workfile_creation_enabled=True) + except TemplateProfileNotFound: + print( + "No workfile template profile enabled for current context. " + "Skipping workfile creation." + ) + cmds.evalDeferred( _log_and_open, lowestPriority=True