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,
|
AVALON_CONTAINER_ID,
|
||||||
)
|
)
|
||||||
from openpype.pipeline.load import any_outdated_containers
|
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 . import menu, lib
|
||||||
from .workio import (
|
from .workio import (
|
||||||
open_file,
|
open_file,
|
||||||
|
|
@ -548,9 +548,10 @@ def on_task_changed():
|
||||||
|
|
||||||
|
|
||||||
def before_workfile_save(event):
|
def before_workfile_save(event):
|
||||||
|
project_name = os.getenv("AVALON_PROJECT")
|
||||||
workdir_path = event["workdir_path"]
|
workdir_path = event["workdir_path"]
|
||||||
if workdir_path:
|
if workdir_path:
|
||||||
load_workspace_mel(workdir_path)
|
create_workspace_mel(workdir_path, project_name)
|
||||||
|
|
||||||
|
|
||||||
class MayaDirmap(HostDirmap):
|
class MayaDirmap(HostDirmap):
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
from openpype.lib import PreLaunchHook
|
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):
|
class PreCopyMel(PreLaunchHook):
|
||||||
|
|
@ -10,9 +10,10 @@ class PreCopyMel(PreLaunchHook):
|
||||||
app_groups = ["maya"]
|
app_groups = ["maya"]
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
|
project_name = self.launch_context.env.get("AVALON_PROJECT")
|
||||||
workdir = self.launch_context.env.get("AVALON_WORKDIR")
|
workdir = self.launch_context.env.get("AVALON_WORKDIR")
|
||||||
if not workdir:
|
if not workdir:
|
||||||
self.log.warning("BUG: Workdir is not filled.")
|
self.log.warning("BUG: Workdir is not filled.")
|
||||||
return
|
return
|
||||||
|
|
||||||
copy_workspace_mel(workdir)
|
create_workspace_mel(workdir, project_name)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
from openpype.settings import get_project_settings
|
||||||
|
|
||||||
from openpype.settings import get_current_project_settings
|
|
||||||
|
|
||||||
|
|
||||||
def load_workspace_mel(workdir):
|
def create_workspace_mel(workdir, project_name):
|
||||||
dst_filepath = os.path.join(workdir, "workspace.mel")
|
dst_filepath = os.path.join(workdir, "workspace.mel")
|
||||||
if os.path.exists(dst_filepath):
|
if os.path.exists(dst_filepath):
|
||||||
return
|
return
|
||||||
|
|
@ -12,9 +10,12 @@ def load_workspace_mel(workdir):
|
||||||
if not os.path.exists(workdir):
|
if not os.path.exists(workdir):
|
||||||
os.makedirs(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:
|
with open(dst_filepath, "w") as mel_file:
|
||||||
setting = get_current_project_settings()
|
mel_file.write(mel_script)
|
||||||
mel_script = setting["maya"]["mel-workspace"]["definition"]
|
|
||||||
for mel in mel_script:
|
|
||||||
mel_file.write(mel)
|
|
||||||
mel_file.write("\n")
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,7 @@
|
||||||
"blender/2-91",
|
"blender/2-91",
|
||||||
"harmony/20",
|
"harmony/20",
|
||||||
"photoshop/2021",
|
"photoshop/2021",
|
||||||
"aftereffects/2021",
|
"aftereffects/2021"
|
||||||
"unreal/4-26"
|
|
||||||
],
|
],
|
||||||
"tools_env": [],
|
"tools_env": [],
|
||||||
"active": true
|
"active": true
|
||||||
|
|
|
||||||
|
|
@ -15,20 +15,7 @@
|
||||||
"destination-path": []
|
"destination-path": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mel-workspace":{
|
"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",
|
||||||
"definition":[
|
|
||||||
"workspace -fr \"shaders\" \"renderData/shaders\";",
|
|
||||||
"workspace -fr \"images\" \"renders\";",
|
|
||||||
"workspace -fr \"particles\" \"particles\";",
|
|
||||||
"workspace -fr \"mayaAscii\" \"\";",
|
|
||||||
"workspace -fr \"mayaBinary\" \"\";",
|
|
||||||
"workspace -fr \"scene\" \"\";",
|
|
||||||
"workspace -fr \"alembicCache\" \"cache/alembic\";",
|
|
||||||
"workspace -fr \"renderData\" \"renderData\";",
|
|
||||||
"workspace -fr \"sourceImages\" \"sourceimages\";",
|
|
||||||
"workspace -fr \"fileCache\" \"cache/nCache\";"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"scriptsmenu": {
|
"scriptsmenu": {
|
||||||
"name": "OpenPype Tools",
|
"name": "OpenPype Tools",
|
||||||
"definition": [
|
"definition": [
|
||||||
|
|
|
||||||
|
|
@ -54,19 +54,10 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "dict",
|
"type": "text",
|
||||||
"collapsible": true,
|
"multiline" : true,
|
||||||
"key": "mel-workspace",
|
"key": "mel_workspace",
|
||||||
"label": "Maya MEL Workspace",
|
"label": "Maya MEL Workspace"
|
||||||
"is_group": true,
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"type": "list",
|
|
||||||
"object_type": "text",
|
|
||||||
"key": "definition",
|
|
||||||
"label": "definition"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "schema",
|
"type": "schema",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue