Bases: InstancePlugin
Collect Backdrop node instance and its content
Source code in client/ayon_nuke/plugins/publish/collect_backdrop.py
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 | class CollectBackdrops(pyblish.api.InstancePlugin):
"""Collect Backdrop node instance and its content
"""
order = pyblish.api.CollectorOrder + 0.22
label = "Collect Backdrop"
hosts = ["nuke"]
families = ["nukenodes"]
settings_category = "nuke"
def process(self, instance):
self.log.debug(pformat(instance.data))
bckn = instance.data["transientData"]["node"]
# define size of the backdrop
left = bckn.xpos()
top = bckn.ypos()
right = left + bckn['bdwidth'].value()
bottom = top + bckn['bdheight'].value()
instance.data["transientData"]["childNodes"] = []
# iterate all nodes
for node in nuke.allNodes():
# exclude viewer
if node.Class() == "Viewer":
continue
# find all related nodes
if (node.xpos() > left) \
and (node.xpos() + node.screenWidth() < right) \
and (node.ypos() > top) \
and (node.ypos() + node.screenHeight() < bottom):
# add contained nodes to instance's node list
instance.data["transientData"]["childNodes"].append(node)
# get all connections from outside of backdrop
nodes = instance.data["transientData"]["childNodes"]
connections_in, connections_out = pnlib.get_dependent_nodes(nodes)
instance.data["transientData"]["nodeConnectionsIn"] = connections_in
instance.data["transientData"]["nodeConnectionsOut"] = connections_out
# make label nicer
instance.data["label"] = "{0} ({1} nodes)".format(
bckn.name(), len(instance.data["transientData"]["childNodes"]))
# get version
version = instance.context.data.get('version')
if version:
instance.data['version'] = version
self.log.debug("Backdrop instance collected: `{}`".format(instance))
|