From a696470fa2ee842ef0e66936e7cfe1630803b9e7 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 29 May 2024 17:16:43 +0800 Subject: [PATCH] add version up workfile in the general ayon core function --- client/ayon_core/hosts/maya/api/commands.py | 15 +-------------- client/ayon_core/hosts/maya/api/menu.py | 9 +++++++++ client/ayon_core/pipeline/context_tools.py | 13 ++++++++++++- package.py | 2 +- server/settings/main.py | 8 +++++++- server_addon/maya/server/settings/scriptsmenu.py | 10 ---------- 6 files changed, 30 insertions(+), 27 deletions(-) diff --git a/client/ayon_core/hosts/maya/api/commands.py b/client/ayon_core/hosts/maya/api/commands.py index 411614c9da..3dcc604d68 100644 --- a/client/ayon_core/hosts/maya/api/commands.py +++ b/client/ayon_core/hosts/maya/api/commands.py @@ -6,10 +6,8 @@ from ayon_api import get_project, get_folder_by_path from ayon_core.pipeline import ( get_current_project_name, - get_current_folder_path, - registered_host + get_current_folder_path ) -from ayon_core.lib import version_up class ToolWindows: @@ -121,14 +119,3 @@ def reset_resolution(): cmds.setAttr(width_attr_name, resolution_width) cmds.setAttr(height_attr_name, resolution_height) - - -def version_up_workfile(): - """Function to increment and save workfile - """ - host = registered_host() - current_file = host.get_current_workfile() - if not current_file: - return None - filepath = version_up(current_file) - host.save_workfile(filepath) diff --git a/client/ayon_core/hosts/maya/api/menu.py b/client/ayon_core/hosts/maya/api/menu.py index e3ef50cdc0..09e4af712a 100644 --- a/client/ayon_core/hosts/maya/api/menu.py +++ b/client/ayon_core/hosts/maya/api/menu.py @@ -25,6 +25,7 @@ from .workfile_template_builder import ( build_workfile_template, update_workfile_template ) +from ayon_core.pipeline.context_tools import version_up_workfile from ayon_core.tools.workfile_template_build import open_template_ui from .workfile_template_builder import MayaTemplateBuilder @@ -76,6 +77,14 @@ def install(project_settings): cmds.menuItem(divider=True) + if project_settings["core"].get("version_up_workfile"): + cmds.menuItem( + "Version Up Workfile", + command=lambda *args: version_up_workfile() + ) + + cmds.menuItem(divider=True) + cmds.menuItem( "Create...", command=lambda *args: host_tools.show_publisher( diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index c32d04c44c..399946cb84 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -11,7 +11,7 @@ from pyblish.lib import MessageHandler from ayon_core import AYON_CORE_ROOT from ayon_core.host import HostBase -from ayon_core.lib import is_in_tests, initialize_ayon_connection, emit_event +from ayon_core.lib import is_in_tests, initialize_ayon_connection, emit_event, version_up from ayon_core.addon import load_addons, AddonsManager from ayon_core.settings import get_project_settings @@ -579,3 +579,14 @@ def get_process_id(): if _process_id is None: _process_id = str(uuid.uuid4()) return _process_id + + +def version_up_workfile(): + """Function to increment and save workfile + """ + host = registered_host() + current_file = host.get_current_workfile() + if not current_file: + return None + filepath = version_up(current_file) + host.save_workfile(filepath) diff --git a/package.py b/package.py index 73f7174b6f..35877ff687 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "0.3.3-dev.1" +version = "0.3.3-dev.2" client_dir = "ayon_core" diff --git a/server/settings/main.py b/server/settings/main.py index 40e16e7e91..1d357897d7 100644 --- a/server/settings/main.py +++ b/server/settings/main.py @@ -219,6 +219,11 @@ class CoreSettings(BaseSettingsModel): title="Project environments", section="---" ) + version_up_workfile: bool = SettingsField( + False, + title="Version Up Workfile", + section="---" + ) @validator( "environments", @@ -313,5 +318,6 @@ DEFAULT_VALUES = { "project_environments": json.dumps( {}, indent=4 - ) + ), + "version_up_workfile": False } diff --git a/server_addon/maya/server/settings/scriptsmenu.py b/server_addon/maya/server/settings/scriptsmenu.py index ef04a92f89..7b0ba7d831 100644 --- a/server_addon/maya/server/settings/scriptsmenu.py +++ b/server_addon/maya/server/settings/scriptsmenu.py @@ -83,16 +83,6 @@ DEFAULT_SCRIPTSMENU_SETTINGS = { "pipeline", "shader" ] - }, - { - "type": "action", - "command": "import openpype.hosts.maya.api.commands as op_cmds; op_cmds.version_up_workfile()", - "sourcetype": "python", - "title": "Version Up", - "tooltip": "Save workfile with upversioning", - "tags": [ - "pipeline" - ] } ], "definition_json": "[]"