diff --git a/openpype/hosts/nuke/plugins/publish/extract_render_local.py b/openpype/hosts/nuke/plugins/publish/extract_render_local.py index 057bca11ac1..1595fe03fb0 100644 --- a/openpype/hosts/nuke/plugins/publish/extract_render_local.py +++ b/openpype/hosts/nuke/plugins/publish/extract_render_local.py @@ -42,12 +42,22 @@ def process(self, instance): self.log.info("Start frame: {}".format(first_frame)) self.log.info("End frame: {}".format(last_frame)) - # write node url might contain nuke's ctl expressin - # as [python ...]/path... - path = node["file"].evaluate() + node_file = node["file"] + # Collecte expected filepaths for each frame + # - for cases that output is still image is first created set of + # paths which is then sorted and converted to list + expected_paths = list(sorted({ + node_file.evaluate(frame) + for frame in range(first_frame, last_frame + 1) + })) + # Extract only filenames for representation + filenames = [ + os.path.basename(filepath) + for filepath in expected_paths + ] # Ensure output directory exists. - out_dir = os.path.dirname(path) + out_dir = os.path.dirname(expected_paths[0]) if not os.path.exists(out_dir): os.makedirs(out_dir) @@ -67,12 +77,11 @@ def process(self, instance): if "representations" not in instance.data: instance.data["representations"] = [] - collected_frames = os.listdir(out_dir) - if len(collected_frames) == 1: + if len(filenames) == 1: repre = { 'name': ext, 'ext': ext, - 'files': collected_frames.pop(), + 'files': filenames[0], "stagingDir": out_dir } else: @@ -81,7 +90,7 @@ def process(self, instance): 'ext': ext, 'frameStart': "%0{}d".format( len(str(last_frame))) % first_frame, - 'files': collected_frames, + 'files': filenames, "stagingDir": out_dir } instance.data["representations"].append(repre) @@ -105,7 +114,7 @@ def process(self, instance): families.remove('still.local') instance.data["families"] = families - collections, remainder = clique.assemble(collected_frames) + collections, remainder = clique.assemble(filenames) self.log.info('collections: {}'.format(str(collections))) if collections: diff --git a/openpype/hosts/nuke/plugins/publish/precollect_writes.py b/openpype/hosts/nuke/plugins/publish/precollect_writes.py index a7c07975e2c..049958bd07d 100644 --- a/openpype/hosts/nuke/plugins/publish/precollect_writes.py +++ b/openpype/hosts/nuke/plugins/publish/precollect_writes.py @@ -56,9 +56,21 @@ def process(self, instance): first_frame = int(node["first"].getValue()) last_frame = int(node["last"].getValue()) - # get path + # Prepare expected output paths by evaluating each frame of write node + # - paths are first collected to set to avoid duplicated paths, then + # sorted and converted to list + node_file = node["file"] + expected_paths = list(sorted({ + node_file.evaluate(frame) + for frame in range(first_frame, last_frame + 1) + })) + expected_filenames = [ + os.path.basename(filepath) + for filepath in expected_paths + ] path = nuke.filename(node) output_dir = os.path.dirname(path) + self.log.debug('output dir: {}'.format(output_dir)) # create label @@ -83,8 +95,11 @@ def process(self, instance): } try: - collected_frames = [f for f in os.listdir(output_dir) - if ext in f] + collected_frames = [ + filename + for filename in os.listdir(output_dir) + if filename in expected_filenames + ] if collected_frames: collected_frames_len = len(collected_frames) frame_start_str = "%0{}d".format(