Support *.nk sources for plates.

This commit is contained in:
Toke Jepsen 2019-06-26 16:34:52 +01:00
parent ae5481d4e3
commit 93ec72767a
2 changed files with 46 additions and 7 deletions

View file

@ -1,6 +1,9 @@
import os
from pyblish import api
import nuke
class CollectClips(api.ContextPlugin):
"""Collect all Track items selection."""
@ -14,7 +17,6 @@ class CollectClips(api.ContextPlugin):
version = context.data.get("version", "001")
instances_data = []
for item in context.data.get("selection", []):
self.log.debug(item)
# Skip audio track items
# Try/Except is to handle items types, like EffectTrackItem
try:
@ -28,6 +30,32 @@ class CollectClips(api.ContextPlugin):
source = item.source().mediaSource()
source_path = source.firstpath()
# If source is *.nk its a comp effect and we need to fetch the
# write node output.
if source_path.endswith(".nk"):
nuke.scriptOpen(source_path)
# There should noly be one.
write_node = nuke.allNodes(filter="Write")[0]
path = nuke.filename(write_node)
if "%" in path:
# Get start frame from Nuke script and use the item source
# in/out, because you can have multiple shots covered with
# one nuke script.
start_frame = int(nuke.root()["first_frame"].getValue())
if write_node["use_limit"].getValue():
start_frame = int(write_node["first"].getValue())
path = path % (start_frame + item.sourceIn())
source_path = path
self.log.debug(
"Fetched source path \"{}\" from \"{}\" in "
"\"{}\".".format(
source_path, write_node.name(), source.firstpath()
)
)
try:
head, padding, ext = os.path.basename(source_path).split(".")
source_first_frame = int(padding)

View file

@ -41,12 +41,19 @@ class CollectPlates(api.ContextPlugin):
data["family"] = "plate"
data["families"] = ["ftrack"]
data["label"] += (
" ({})".format(os.path.splitext(data["sourcePath"])[1])
)
data["subset"] = dict(tag["metadata"])["tag.subset"]
data["source"] = data["sourcePath"]
subset = ""
for tag in instance.data["tags"]:
tag_data = dict(tag["metadata"])
if "tag.subset" in tag_data:
subset = tag_data["tag.subset"]
data["subset"] = subset
data["label"] += " - {} - ({})".format(
subset, os.path.splitext(data["sourcePath"])[1]
)
# Timeline data.
handle_start = int(instance.data["handleStart"] + data["handles"])
handle_end = int(instance.data["handleEnd"] + data["handles"])
@ -173,10 +180,14 @@ class CollectPlatesData(api.InstancePlugin):
self.log.debug("__ s duration: {}".format(source_out - source_in + 1))
self.log.debug("__ source_in_h: {}".format(source_in_h))
self.log.debug("__ source_out_h: {}".format(source_out_h))
self.log.debug("__ sh duration: {}".format(source_out_h - source_in_h + 1))
self.log.debug("__ sh duration: {}".format(
source_out_h - source_in_h + 1)
)
self.log.debug("__ timeline_in: {}".format(timeline_in))
self.log.debug("__ timeline_out: {}".format(timeline_out))
self.log.debug("__ t duration: {}".format(timeline_out - timeline_in + 1))
self.log.debug("__ t duration: {}".format(
timeline_out - timeline_in + 1)
)
self.log.debug("__ timeline_frame_start: {}".format(
timeline_frame_start))
self.log.debug("__ timeline_frame_end: {}".format(timeline_frame_end))