forked from shotgunsoftware/tk-nuke-writenode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
executable file
·176 lines (138 loc) · 5.11 KB
/
app.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# 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.
from sgtk.platform import Application
import nuke
import os
class TkNukeWriteNode(Application):
"""
The tk_nuke_writenode entry point. This class is responsible for initializing and tearing down
the application, handle menu registration etc.
"""
def init_app(self):
"""
Called as the application is being initialized
"""
self.tk_nuke_writenode = self.import_module("tk_nuke_writenode")
self.handler = self.tk_nuke_writenode.NukeWriteNodeHandler()
# Registering commands
create_write_node = lambda: self.handler.create_writenode()
self.engine.register_command(
"NFA ShotGrid Write Node",
create_write_node,
dict(
type="node",
icon="Write.png",
hotkey="w",
context=self.context,
),
)
read_from_write = lambda: self.handler.read_from_selected()
self.engine.register_command(
"Create Read from Write",
read_from_write,
dict(
type="menu",
icon="Read.png",
hotkey="ctrl+r",
context=self.context,
),
)
# Adding callbacks
self.handler.add_callbacks()
def destroy_app(self):
self.log_debug("Destroying tk-nuke-writenode app")
self.handler.remove_callbacks()
def render_local(self, node):
"""Function to start rendering locally. Will set paths and render.
Args:
node (object): node to render locally
"""
self.handler.render_local(node)
def render_farm(self, node):
"""Function to start rendering on farm. Will set paths and
use Deadline submission.
Args:
node (object): node to submit for render on farm
"""
self.handler.render_farm(node)
def knob_changed(self, node, knob):
"""Function called whenever any knob changes on
the ShotGrid write node
Args:
node (attribute): node to process
knob (attribute): knob that has changed
"""
self.handler.knob_changed(node, knob)
def read_from_write(self, node):
"""Creates a read node from the selected write node
Args:
node (object): node to create read node from
"""
self.handler.read_from_write(node)
def get_all_write_nodes(self):
"""This function will return all existing ShotGrid write nodes
in the current script
Returns:
list: containing every ShotGrid write node
"""
write_nodes = self.handler.get_all_write_nodes()
return write_nodes
def get_node_render_template(self, node):
"""Returns the render template used by the selected node
Args:
node (object): specific node to get the render template
Returns:
object: render template by ShotGrid template.yml
"""
render_template = self.handler.get_node_render_template(node)
return render_template
def get_node_publish_template(self, node):
"""Returns the publish template used by the selected node
Args:
node (object): specific node to get the publish template
Returns:
object: publish template by ShotGrid template.yml
"""
publish_template = self.handler.get_node_publish_template(node)
return publish_template
def get_published_status(self, node):
"""Check if selected node is already published
Args:
node (object): node to check for publishes
Returns:
bool: returns True if node is published, False if not
"""
is_published = self.handler.get_published_status(node)
return is_published
def get_colorspace(self, node):
"""Get the colorspace the selected node is rendering
Args:
node (object): node to retrieve current colorspace
Returns:
str: colorspace used
"""
colorspace = self.handler.get_colorspace(node)
return colorspace
def update_read_nodes(self):
"""Update all read nodes to use the published path"""
self.handler.update_read_nodes()
def convert_placeholder_nodes(self):
"""Converts NoOp nodes used in the template to convert to
ShotGrid write nodes
"""
self.handler.convert_placeholder_nodes()
@staticmethod
def get_write_nodes():
"""Empty function for legacy reasons to reset all
render paths on file save, which is not what we want
Returns:
list: empty
"""
return []