mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
adding and loading maya mel workspace through openpype project setting
This commit is contained in:
parent
69d2cf20f5
commit
26fbdac8da
6 changed files with 22 additions and 42 deletions
|
|
@ -28,7 +28,7 @@ from openpype.pipeline import (
|
|||
AVALON_CONTAINER_ID,
|
||||
)
|
||||
from openpype.pipeline.load import any_outdated_containers
|
||||
from openpype.hosts.maya.lib import load_workspace_mel
|
||||
from openpype.hosts.maya.lib import create_workspace_mel
|
||||
from . import menu, lib
|
||||
from .workio import (
|
||||
open_file,
|
||||
|
|
@ -548,9 +548,10 @@ def on_task_changed():
|
|||
|
||||
|
||||
def before_workfile_save(event):
|
||||
project_name = os.getenv("AVALON_PROJECT")
|
||||
workdir_path = event["workdir_path"]
|
||||
if workdir_path:
|
||||
load_workspace_mel(workdir_path)
|
||||
create_workspace_mel(workdir_path, project_name)
|
||||
|
||||
|
||||
class MayaDirmap(HostDirmap):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import os
|
||||
import shutil
|
||||
|
||||
from openpype.settings import get_current_project_settings
|
||||
from openpype.settings import get_project_settings
|
||||
|
||||
|
||||
def load_workspace_mel(workdir):
|
||||
def create_workspace_mel(workdir, project_name):
|
||||
dst_filepath = os.path.join(workdir, "workspace.mel")
|
||||
if os.path.exists(dst_filepath):
|
||||
return
|
||||
|
|
@ -12,9 +10,12 @@ def load_workspace_mel(workdir):
|
|||
if not os.path.exists(workdir):
|
||||
os.makedirs(workdir)
|
||||
|
||||
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:
|
||||
return
|
||||
|
||||
with open(dst_filepath, "w") as mel_file:
|
||||
setting = get_current_project_settings()
|
||||
mel_script = setting["maya"]["mel-workspace"]["definition"]
|
||||
for mel in mel_script:
|
||||
mel_file.write(mel)
|
||||
mel_file.write("\n")
|
||||
mel_file.write(mel_script)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue