Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6186 from Sponge96/max_tweaks
Browse files Browse the repository at this point in the history
Max: updated implementation of save_scene + small QOL improvements to host
  • Loading branch information
moonyuet authored Feb 14, 2024
2 parents b15643e + 93e84b3 commit e020ca7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
5 changes: 2 additions & 3 deletions openpype/hosts/max/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ def context_setting():
rt.callbacks.addScript(rt.Name('postWorkspaceChange'),
self._deferred_menu_creation)

def has_unsaved_changes(self):
# TODO: how to get it from 3dsmax?
return True
def workfile_has_unsaved_changes(self):
return rt.getSaveRequired()

def get_workfile_extensions(self):
return [".max"]
Expand Down
22 changes: 12 additions & 10 deletions openpype/hosts/max/plugins/publish/save_scene.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import pyblish.api
import os
from openpype.pipeline import registered_host


class SaveCurrentScene(pyblish.api.ContextPlugin):
"""Save current scene
"""
"""Save current scene"""

label = "Save current file"
order = pyblish.api.ExtractorOrder - 0.49
hosts = ["max"]
families = ["maxrender", "workfile"]

def process(self, context):
from pymxs import runtime as rt
folder = rt.maxFilePath
file = rt.maxFileName
current = os.path.join(folder, file)
assert context.data["currentFile"] == current
rt.saveMaxFile(current)
host = registered_host()
current_file = host.get_current_workfile()

assert context.data["currentFile"] == current_file

if host.workfile_has_unsaved_changes():
self.log.info(f"Saving current file: {current_file}")
host.save_workfile(current_file)
else:
self.log.debug("No unsaved changes, skipping file save..")
5 changes: 4 additions & 1 deletion openpype/hosts/max/startup/startup.ms
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

local pythonpath = systemTools.getEnvVariable "MAX_PYTHONPATH"
systemTools.setEnvVariable "PYTHONPATH" pythonpath

/*opens the create menu on startup to ensure users are presented with a useful default view.*/
max create mode

python.ExecuteFile startup
)
)

0 comments on commit e020ca7

Please sign in to comment.