# Copyright (c) 2013 Shotgun Software Inc. # # CONFIDENTIAL AND PROPRIETARY # # This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit # Source Code License included in this distribution package. See LICENSE. # By accessing, using, copying or modifying this work you indicate your # agreement to the Shotgun Pipeline Toolkit Source Code License. All rights # not expressly granted therein are reserved by Shotgun Software Inc. import os import sgtk HookClass = sgtk.get_hook_baseclass() __author__ = "Diego Garcia Huerta" __contact__ = "https://www.linkedin.com/in/diegogh/" class SceneOperation(HookClass): """ Hook called to perform an operation with the current scene """ def execute(self, operation, file_path, **kwargs): """ Main hook entry point :operation: String Scene operation to perform :file_path: String File path to use if the operation requires it (e.g. open) :returns: Depends on operation: 'current_path' - Return the current scene file path as a String all others - None """ app = self.parent engine = sgtk.platform.current_engine() dcc_app = engine.app if operation == "current_path": return dcc_app.get_current_project_path() elif operation == "open": dcc_app.open_project(file_path) elif operation == "save": dcc_app.save_project()