From 93ec72767a97a1cf0f87f5486379e667061a0c88 Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Wed, 26 Jun 2019 16:34:52 +0100 Subject: [PATCH] Support *.nk sources for plates. --- .../nukestudio/publish/collect_clips.py | 30 ++++++++++++++++++- .../nukestudio/publish/collect_plates.py | 23 ++++++++++---- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/pype/plugins/nukestudio/publish/collect_clips.py b/pype/plugins/nukestudio/publish/collect_clips.py index f705186ffe..8025bbcd02 100644 --- a/pype/plugins/nukestudio/publish/collect_clips.py +++ b/pype/plugins/nukestudio/publish/collect_clips.py @@ -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) diff --git a/pype/plugins/nukestudio/publish/collect_plates.py b/pype/plugins/nukestudio/publish/collect_plates.py index e45b147096..41d0f346f8 100644 --- a/pype/plugins/nukestudio/publish/collect_plates.py +++ b/pype/plugins/nukestudio/publish/collect_plates.py @@ -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))