diff --git a/pype/plugins/nuke/create/create_read.py b/pype/plugins/nuke/create/create_read.py index 6465315d37..495cdde0ad 100644 --- a/pype/plugins/nuke/create/create_read.py +++ b/pype/plugins/nuke/create/create_read.py @@ -1,7 +1,6 @@ from collections import OrderedDict import avalon.api import avalon.nuke -from pype.nuke import create_write_node from pype import api as pype import nuke @@ -34,20 +33,23 @@ class CrateRead(avalon.nuke.Creator): nodes = nuke.selectedNodes() - if not nodes: + if not nodes or len(nodes) == 0: nuke.message('Please select Read node') elif len(nodes) == 1: if nodes[0].Class() != 'Read': nuke.message('Please select Read node') else: - node = nodes[0] name = node["name"].value() avalon_data = self.data avalon_data['subset'] = "{}_{}".format(self.family, name) change_read_node(self.data["subset"], node, avalon_data) else: - nuke.message('Please select only one Read node') + for node in nodes: + name = node["name"].value() + avalon_data = self.data + avalon_data['subset'] = "{}_{}".format(self.family, name) + change_read_node(self.data["subset"], node, avalon_data) return diff --git a/pype/plugins/nuke/publish/collect_instances.py b/pype/plugins/nuke/publish/collect_instances.py index 91f4fcaac8..9cc835570e 100644 --- a/pype/plugins/nuke/publish/collect_instances.py +++ b/pype/plugins/nuke/publish/collect_instances.py @@ -44,12 +44,12 @@ class CollectNukeInstances(pyblish.api.ContextPlugin): "label": node.name(), "name": node.name(), "subset": subset, - "families": [avalon_knob_data["families"]], "family": avalon_knob_data["family"], "avalonKnob": avalon_knob_data, "publish": node.knob('publish') - }) + if node.Class() == "Write": + instance.data["families"] = [avalon_knob_data["families"]] self.log.info("collected instance: {}".format(instance.data)) instances.append(instance) diff --git a/pype/plugins/nuke/publish/collect_reades.py b/pype/plugins/nuke/publish/collect_reads.py similarity index 51% rename from pype/plugins/nuke/publish/collect_reades.py rename to pype/plugins/nuke/publish/collect_reads.py index 110556e61e..e51967af91 100644 --- a/pype/plugins/nuke/publish/collect_reades.py +++ b/pype/plugins/nuke/publish/collect_reads.py @@ -1,6 +1,6 @@ import os import re - +import clique import nuke import pyblish.api import logging @@ -10,12 +10,12 @@ log = logging.getLogger(__name__) @pyblish.api.log -class CollectNukeWrites(pyblish.api.ContextPlugin): - """Collect all write nodes.""" +class CollectNukeReads(pyblish.api.ContextPlugin): + """Collect all read nodes.""" order = pyblish.api.CollectorOrder + 0.1 - label = "Collect Writes" - hosts = ["nuke", "nukeassist"] + label = "Collect Reads" + hosts = ["nuke"] def process(self, context): asset_data = io.find_one({"type": "asset", @@ -29,67 +29,64 @@ class CollectNukeWrites(pyblish.api.ContextPlugin): continue file_path = node["file"].value() - items = file_path.split(".") + file_name = os.path.basename(file_path) + items = file_name.split(".") + + if len(items) < 2: + raise ValueError + + ext = items[-1] isSequence = False if len(items) > 1: sequence = items[-2] - print sequence - hash_regex = re.compile(r"([#*])") + hash_regex = re.compile(r'([#*])') seq_regex = re.compile('[%0-9*d]') hash_match = re.match(hash_regex, sequence) seq_match = re.match(seq_regex, sequence) - if hash_match is True or seq_match is True: + if hash_match or seq_match: isSequence = True - # Get frame range - first_frame = int(nuke.root()["first_frame"].getValue()) - last_frame = int(nuke.root()["last_frame"].getValue()) - - if node["use_limit"].getValue(): - first_frame = int(node["first"].getValue()) - last_frame = int(node["last"].getValue()) + # # Get frame range + # first_frame = int(nuke.root()["first_frame"].getValue()) + # last_frame = int(nuke.root()["last_frame"].getValue()) + first_frame = node['first'].value() + last_frame = node['last'].value() # get source path - source_path = nuke.filename(node) - source_dir = os.path.dirname(source_path) + path = nuke.filename(node) + source_dir = os.path.dirname(path) self.log.debug('source dir: {}'.format(source_dir)) + + if isSequence: + # collections, remainder = clique.assemble(os.listdir(source_dir)) + # source_files = collections[0] + source_files = os.listdir(source_dir) + else: + source_files = file_name + # Include start and end render frame in label name = node.name() - label = "{0} ({1}-{2})".format( name, int(first_frame), int(last_frame) ) - - # preredered frames - if not node["render"].value(): - families = "prerendered.frames" - collected_frames = os.listdir(output_dir) - self.log.debug("collected_frames: {}".format(label)) - if "files" not in instance.data: - instance.data["files"] = list() - instance.data["files"].append(collected_frames) - instance.data['transfer'] = False - else: - # dealing with local/farm rendering - if node["render_farm"].value(): - families = "{}.farm".format(instance.data["avalonKnob"]["families"][0]) - else: - families = "{}.local".format(instance.data["avalonKnob"]["families"][0]) + nuke.message(str(source_files)) + self.log.debug("collected_frames: {}".format(label)) + if "files" not in instance.data: + instance.data["files"] = list() + instance.data["files"] = source_files + instance.data['transfer'] = False self.log.debug("checking for error: {}".format(label)) instance.data.update({ "path": path, - "outputDir": output_dir, + "stagingDir": source_dir, "ext": ext, "label": label, - "families": [families, 'ftrack'], "startFrame": first_frame, "endFrame": last_frame, - "outputType": output_type, - "stagingDir": output_dir, "colorspace": node["colorspace"].value(), "handles": int(asset_data["data"].get("handles", 0)), "step": 1, @@ -99,7 +96,3 @@ class CollectNukeWrites(pyblish.api.ContextPlugin): self.log.debug("instance.data: {}".format(instance.data)) self.log.debug("context: {}".format(context)) - - def sort_by_family(self, instance): - """Sort by family""" - return instance.data.get("families", instance.data.get("family")) diff --git a/pype/plugins/nuke/publish/integrate_rendered_frames.py b/pype/plugins/nuke/publish/integrate_rendered_frames.py index 8c178df4e4..df6734b0c9 100644 --- a/pype/plugins/nuke/publish/integrate_rendered_frames.py +++ b/pype/plugins/nuke/publish/integrate_rendered_frames.py @@ -24,7 +24,7 @@ class IntegrateFrames(pyblish.api.InstancePlugin): label = "Integrate Frames" order = pyblish.api.IntegratorOrder - families = ["prerendered.frames"] + families = ["prerendered.frames", "source"] def process(self, instance):