Skip to content

Commit 5755c97

Browse files
authored
Merge pull request #22 from ynput/enhancement/AY-7169_Callback-action-for-project-creation-when-Max-launches
Set the correct project folder accordingly to Ayon workdir
2 parents 7d92d59 + 54f39cb commit 5755c97

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

client/ayon_max/api/pipeline.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ def install(self):
5252
register_creator_plugin_path(CREATE_PATH)
5353

5454
_set_project()
55+
lib.set_context_setting()
5556

5657
self.menu = AYONMenu()
5758

5859
register_event_callback("workfile.open.before", on_before_open)
5960
self._has_been_setup = True
60-
6161
rt.callbacks.addScript(rt.Name('systemPostNew'), on_new)
6262

6363
rt.callbacks.addScript(rt.Name('filePostOpen'),
@@ -214,13 +214,17 @@ def containerise(name: str, nodes: list, context,
214214
def _set_project():
215215
project_name = get_current_project_name()
216216
project_settings = get_project_settings(project_name)
217+
workdir = os.getenv("AYON_WORKDIR")
218+
os.makedirs(workdir, exist_ok=True)
219+
rt.pathConfig.setCurrentProjectFolder(workdir)
217220
enable_project_creation = project_settings["max"].get("enabled_project_creation")
218-
if not enable_project_creation:
221+
if enable_project_creation:
222+
directory_count = rt.pathConfig.getProjectSubDirectoryCount()
223+
autobackup_dir = rt.pathConfig.GetDir(rt.Name("autoback"))
224+
os.makedirs(autobackup_dir, exist_ok=True)
219225
log.debug("Project creation disabled. Skipping project creation.")
220226
return
221-
workdir = os.getenv("AYON_WORKDIR")
222227

223-
os.makedirs(workdir, exist_ok=True)
224228
mxp_filepath = os.path.join(workdir, "workspace.mxp")
225229
if os.path.exists(mxp_filepath):
226230
rt.pathConfig.load(mxp_filepath)
@@ -229,7 +233,6 @@ def _set_project():
229233
proj_dir = rt.pathConfig.getProjectSubDirectory(count)
230234
if proj_dir:
231235
os.makedirs(proj_dir, exist_ok=True)
232-
rt.pathConfig.setCurrentProjectFolder(workdir)
233236

234237

235238
def on_before_open():

0 commit comments

Comments
 (0)