Merge branch 'develop' into feature/OP-3845_nuke-convert-to-new-publisher

This commit is contained in:
Jakub Jezek 2022-09-13 13:38:43 +02:00
commit 4093e0eb9e
No known key found for this signature in database
GPG key ID: 730D7C02726179A7
7 changed files with 67 additions and 34 deletions

View file

@ -32,7 +32,7 @@ from openpype.pipeline import (
)
from openpype.pipeline.load import any_outdated_containers
from openpype.hosts.maya import MAYA_ROOT_DIR
from openpype.hosts.maya.lib import copy_workspace_mel
from openpype.hosts.maya.lib import create_workspace_mel
from . import menu, lib
from .workio import (
@ -63,7 +63,7 @@ class MayaHost(HostBase, IWorkfileHost, ILoadHost):
self._op_events = {}
def install(self):
project_name = os.getenv("AVALON_PROJECT")
project_name = legacy_io.active_project()
project_settings = get_project_settings(project_name)
# process path mapping
dirmap_processor = MayaDirmap("maya", project_name, project_settings)
@ -533,7 +533,7 @@ def on_task_changed():
lib.update_content_on_context_change()
msg = " project: {}\n asset: {}\n task:{}".format(
legacy_io.Session["AVALON_PROJECT"],
legacy_io.active_project(),
legacy_io.Session["AVALON_ASSET"],
legacy_io.Session["AVALON_TASK"]
)
@ -545,9 +545,10 @@ def on_task_changed():
def before_workfile_save(event):
project_name = legacy_io.active_project()
workdir_path = event["workdir_path"]
if workdir_path:
copy_workspace_mel(workdir_path)
create_workspace_mel(workdir_path, project_name)
class MayaDirmap(HostDirmap):

View file

@ -1,5 +1,5 @@
from openpype.lib import PreLaunchHook
from openpype.hosts.maya.lib import copy_workspace_mel
from openpype.hosts.maya.lib import create_workspace_mel
class PreCopyMel(PreLaunchHook):
@ -10,9 +10,10 @@ class PreCopyMel(PreLaunchHook):
app_groups = ["maya"]
def execute(self):
project_name = self.launch_context.env.get("AVALON_PROJECT")
workdir = self.launch_context.env.get("AVALON_WORKDIR")
if not workdir:
self.log.warning("BUG: Workdir is not filled.")
return
copy_workspace_mel(workdir)
create_workspace_mel(workdir, project_name)

View file

@ -1,26 +1,24 @@
import os
import shutil
from openpype.settings import get_project_settings
from openpype.lib import Logger
def copy_workspace_mel(workdir):
# Check that source mel exists
current_dir = os.path.dirname(os.path.abspath(__file__))
src_filepath = os.path.join(current_dir, "resources", "workspace.mel")
if not os.path.exists(src_filepath):
print("Source mel file does not exist. {}".format(src_filepath))
return
# Skip if workspace.mel already exists
def create_workspace_mel(workdir, project_name):
dst_filepath = os.path.join(workdir, "workspace.mel")
if os.path.exists(dst_filepath):
return
# Create workdir if does not exists yet
if not os.path.exists(workdir):
os.makedirs(workdir)
# Copy file
print("Copying workspace mel \"{}\" -> \"{}\"".format(
src_filepath, dst_filepath
))
shutil.copy(src_filepath, dst_filepath)
project_setting = get_project_settings(project_name)
mel_script = project_setting["maya"].get("mel_workspace")
# Skip if mel script in settings is empty
if not mel_script:
log = Logger.get_logger("create_workspace_mel")
log.debug("File 'workspace.mel' not created. Settings value is empty.")
return
with open(dst_filepath, "w") as mel_file:
mel_file.write(mel_script)

View file

@ -1,11 +0,0 @@
//Maya 2018 Project Definition
workspace -fr "shaders" "renderData/shaders";
workspace -fr "alembicCache" "cache/alembic";
workspace -fr "mayaAscii" "";
workspace -fr "mayaBinary" "";
workspace -fr "renderData" "renderData";
workspace -fr "fileCache" "cache/nCache";
workspace -fr "scene" "";
workspace -fr "sourceImages" "sourceimages";
workspace -fr "images" "renders";

View file

@ -1,4 +1,5 @@
{
"mel_workspace": "workspace -fr \"shaders\" \"renderData/shaders\";\nworkspace -fr \"images\" \"renders\";\nworkspace -fr \"particles\" \"particles\";\nworkspace -fr \"mayaAscii\" \"\";\nworkspace -fr \"mayaBinary\" \"\";\nworkspace -fr \"scene\" \"\";\nworkspace -fr \"alembicCache\" \"cache/alembic\";\nworkspace -fr \"renderData\" \"renderData\";\nworkspace -fr \"sourceImages\" \"sourceimages\";\nworkspace -fr \"fileCache\" \"cache/nCache\";\n",
"ext_mapping": {
"model": "ma",
"mayaAscii": "ma",

View file

@ -5,6 +5,13 @@
"label": "Maya",
"is_file": true,
"children": [
{
"type": "text",
"multiline" : true,
"use_label_wrap": true,
"key": "mel_workspace",
"label": "Maya MEL Workspace"
},
{
"type": "dict-modifiable",
"key": "ext_mapping",

View file

@ -32,6 +32,7 @@ class HostToolsHelper:
self._workfiles_tool = None
self._loader_tool = None
self._creator_tool = None
self._publisher_tool = None
self._subset_manager_tool = None
self._scene_inventory_tool = None
self._library_loader_tool = None
@ -193,7 +194,6 @@ class HostToolsHelper:
library_loader_tool.showNormal()
library_loader_tool.refresh()
def show_publish(self, parent=None):
"""Try showing the most desirable publish GUI
@ -269,6 +269,31 @@ class HostToolsHelper:
dialog.activateWindow()
dialog.showNormal()
def get_publisher_tool(self, parent):
"""Create, cache and return publisher window."""
if self._publisher_tool is None:
from openpype.tools.publisher import PublisherWindow
host = registered_host()
ILoadHost.validate_load_methods(host)
publisher_window = PublisherWindow(
parent=parent or self._parent
)
self._publisher_tool = publisher_window
return self._publisher_tool
def show_publisher_tool(self, parent=None):
with qt_app_context():
dialog = self.get_publisher_tool(parent)
dialog.show()
dialog.raise_()
dialog.activateWindow()
dialog.showNormal()
def get_tool_by_name(self, tool_name, parent=None, *args, **kwargs):
"""Show tool by it's name.
@ -298,6 +323,10 @@ class HostToolsHelper:
elif tool_name == "publish":
self.log.info("Can't return publish tool window.")
# "new" publisher
elif tool_name == "publisher":
return self.get_publisher_tool(parent, *args, **kwargs)
elif tool_name == "experimental_tools":
return self.get_experimental_tools_dialog(parent, *args, **kwargs)
@ -335,6 +364,9 @@ class HostToolsHelper:
elif tool_name == "publish":
self.show_publish(parent, *args, **kwargs)
elif tool_name == "publisher":
self.show_publisher_tool(parent, *args, **kwargs)
elif tool_name == "experimental_tools":
self.show_experimental_tools_dialog(parent, *args, **kwargs)
@ -414,6 +446,10 @@ def show_publish(parent=None):
_SingletonPoint.show_tool_by_name("publish", parent)
def show_publisher(parent=None):
_SingletonPoint.show_tool_by_name("publisher", parent)
def show_experimental_tools_dialog(parent=None):
_SingletonPoint.show_tool_by_name("experimental_tools", parent)