feat(nuke): adding label to collect backdrop

This commit is contained in:
Jakub Jezek 2019-11-22 11:50:31 +01:00
parent 2e82c80e8a
commit a2f81fbdb0

View file

@ -1,11 +1,13 @@
import pyblish.api
import nuke
@pyblish.api.log
class CollectBackdrops(pyblish.api.InstancePlugin):
"""Collect Backdrop instance from rendered frames
"""Collect Backdrop node instance and its content
"""
order = pyblish.api.CollectorOrder + 0.3
order = pyblish.api.CollectorOrder + 0.22
label = "Collect Backdrop"
hosts = ["nuke"]
families = ["nukenodes"]
@ -14,21 +16,30 @@ class CollectBackdrops(pyblish.api.InstancePlugin):
bckn = instance[0]
# define size of the backdrop
left = bckn.xpos()
top = bckn.ypos()
right = left + bckn['bdwidth'].value()
bottom = top + bckn['bdheight'].value()
inNodes = []
# 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):
inNodes.append(node)
self.log.info("Backdrop content collected: `{}`".format(inNodes))
# add contained nodes to instance's node list
instance.append(node)
instance.data["label"] = "{0} ({1} nodes)".format(
bckn.name(), len(instance)-1)
self.log.info("Backdrop content collected: `{}`".format(instance[:]))
self.log.info("Backdrop instance collected: `{}`".format(instance))