mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-27 14:22:37 +01:00
add mxp for pre-hook and new lib for mxp creation
This commit is contained in:
parent
04fc555fe8
commit
b0d65197ba
4 changed files with 85 additions and 1 deletions
23
client/ayon_core/hosts/max/hooks/pre_copy_mxp.py
Normal file
23
client/ayon_core/hosts/max/hooks/pre_copy_mxp.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from ayon_applications import PreLaunchHook, LaunchTypes
|
||||
from ayon_core.hosts.max.lib import create_workspace_mxp
|
||||
|
||||
|
||||
class PreCopyMxp(PreLaunchHook):
|
||||
"""Copy workspace.mxp to workdir.
|
||||
|
||||
Hook `GlobalHostDataHook` must be executed before this hook.
|
||||
"""
|
||||
app_groups = {"3dsmax", "adsk_3dsmax"}
|
||||
launch_types = {LaunchTypes.local}
|
||||
|
||||
def execute(self):
|
||||
project_entity = self.data["project_entity"]
|
||||
workdir = self.launch_context.env.get("AYON_WORKDIR")
|
||||
if not workdir:
|
||||
self.log.warning("BUG: Workdir is not filled.")
|
||||
return
|
||||
|
||||
project_settings = self.data["project_settings"]
|
||||
create_workspace_mxp(
|
||||
workdir, project_entity["name"], project_settings
|
||||
)
|
||||
29
client/ayon_core/hosts/max/lib.py
Normal file
29
client/ayon_core/hosts/max/lib.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
from ayon_core.settings import get_project_settings
|
||||
from ayon_core.lib import Logger
|
||||
|
||||
|
||||
def create_workspace_mxp(workdir, project_name, project_settings=None):
|
||||
dst_filepath = os.path.join(workdir, "workspace.mxp")
|
||||
if os.path.exists(dst_filepath):
|
||||
return
|
||||
|
||||
if not os.path.exists(workdir):
|
||||
os.makedirs(workdir)
|
||||
|
||||
if not project_settings:
|
||||
project_settings = get_project_settings(project_name)
|
||||
max_script = project_settings["max"].get("mxp_workspace")
|
||||
directory_index = max_script.find("[Directories]")
|
||||
max_script = "{}ProjectFolder={}{}".format(
|
||||
max_script[:directory_index], workdir, max_script[directory_index:])
|
||||
print(max_script)
|
||||
|
||||
# Skip if mxp script in settings is empty
|
||||
if not max_script:
|
||||
log = Logger.get_logger("create_workspace_mxp")
|
||||
log.debug("File 'workspace.mxp' not created. Settings value is empty.")
|
||||
return
|
||||
|
||||
with open(dst_filepath, "w") as mxp_file:
|
||||
mxp_file.write(max_script)
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
name = "max"
|
||||
title = "Max"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ class MaxSettings(BaseSettingsModel):
|
|||
default_factory=UnitScaleSettings,
|
||||
title="Set Unit Scale"
|
||||
)
|
||||
mxp_workspace: str = SettingsField(
|
||||
title="Max mxp Workspace", widget="textarea"
|
||||
)
|
||||
imageio: ImageIOSettings = SettingsField(
|
||||
default_factory=ImageIOSettings,
|
||||
title="Color Management (ImageIO)"
|
||||
|
|
@ -67,11 +70,40 @@ class MaxSettings(BaseSettingsModel):
|
|||
title="Publish Plugins")
|
||||
|
||||
|
||||
DEFAULT_MXP_WORKSPACE_SETTINGS = "\n".join((
|
||||
'[Directories]',
|
||||
'Animations= ./sceneassets/animations',
|
||||
'Archives=./archives',
|
||||
'AutoBackup=./autoback',
|
||||
'BitmapProxies=./proxies',
|
||||
'Fluid Simulations=./SimCache',
|
||||
'Images=./sceneassets/images',
|
||||
'MaxStart=./',
|
||||
'Previews=./previews',
|
||||
'RenderAssets=./sceneassets/renderassets',
|
||||
'Scenes=./',
|
||||
'Sounds=./sceneassets/sounds',
|
||||
'[XReferenceDirs]',
|
||||
'Dir1=./',
|
||||
'[BitmapDirs]',
|
||||
'Dir1=C:/Program Files/Autodesk/3ds Max 2023/Maps',
|
||||
'Dir2=C:/Program Files/Autodesk/3ds Max 2023/Maps/glare',
|
||||
'Dir3=C:/Program Files/Autodesk/3ds Max 2023/Maps/adskMtl',
|
||||
'Dir4=C:/Program Files/Autodesk/3ds Max 2023/Maps/Noise',
|
||||
'Dir5=C:/Program Files/Autodesk/3ds Max 2023/Maps/mental_mill',
|
||||
'Dir6=C:/Program Files/Autodesk/3ds Max 2023/Maps/fx',
|
||||
'Dir7=C:/Program Files/Autodesk/3ds Max 2023/Maps/Particle Flow Presets',
|
||||
'',
|
||||
))
|
||||
|
||||
|
||||
|
||||
DEFAULT_VALUES = {
|
||||
"unit_scale_settings": {
|
||||
"enabled": True,
|
||||
"scene_unit_scale": "Centimeters"
|
||||
},
|
||||
"mxp_workspace": DEFAULT_MXP_WORKSPACE_SETTINGS,
|
||||
"RenderSettings": DEFAULT_RENDER_SETTINGS,
|
||||
"CreateReview": DEFAULT_CREATE_REVIEW_SETTINGS,
|
||||
"PointCloud": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue