-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathscene_operation_tk-harmony.py
54 lines (41 loc) · 1.54 KB
/
scene_operation_tk-harmony.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 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()