Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions hooks/scene_operation_tk-hiero.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ def execute(self, operation, file_path, context, parent_action, file_version, re
# save the current script:
project = self._get_current_project()
project.save()

self.set_project_root(project)

elif operation == "save_as":
project = self._get_current_project()
project.saveAs(file_path.replace(os.path.sep, "/"))

self.set_project_root(project)

elif operation == "reset":
# do nothing and indicate scene was reset to empty
Expand Down Expand Up @@ -117,3 +121,14 @@ def _get_current_project(self):
raise TankError("Please select a Hiero Project!")

return project


def set_project_root(self, project):
""" If we're saving inside this SGTK project, set the
projectroot.
"""
sgtk_project_path = self.parent.tank.project_path

if (project.path().startswith(sgtk_project_path) and
not project.projectRoot().startswith(sgtk_project_path)):
project.setProjectRoot(sgtk_project_path)