From 8e813bfd2dfe76193ceeff6a71ed859e7b332710 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 9 Jul 2019 18:57:01 +0200 Subject: [PATCH 1/4] fix(nuke): set frame range and set resolution to new data --- pype/nuke/lib.py | 95 ++++++++++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/pype/nuke/lib.py b/pype/nuke/lib.py index 4d96e6b772..247780855b 100644 --- a/pype/nuke/lib.py +++ b/pype/nuke/lib.py @@ -384,19 +384,26 @@ def reset_frame_range_handles(): log.info("__ handle_start: `{}`".format(handle_start)) log.info("__ handle_end: `{}`".format(handle_end)) - edit_in = int(asset["data"]["fstart"]) - handles - handle_start - edit_out = int(asset["data"]["fend"]) + handles + handle_end + edit_in = int(asset["data"]["fstart"]) - handle_start + edit_out = int(asset["data"]["fend"]) + handle_end nuke.root()["first_frame"].setValue(edit_in) nuke.root()["last_frame"].setValue(edit_out) # setting active viewers + nuke.frame(int(asset["data"]["fstart"])) + vv = nuke.activeViewer().node() - vv['frame_range_lock'].setValue(True) - vv['frame_range'].setValue('{0}-{1}'.format( + + range = '{0}-{1}'.format( int(asset["data"]["fstart"]), int(asset["data"]["fend"])) - ) + + vv['frame_range'].setValue(range) + vv['frame_range_lock'].setValue(True) + + log.info("_frameRange: {}".format(range)) + log.info("frameRange: {}".format(vv['frame_range'].value())) def get_avalon_knob_data(node): @@ -416,20 +423,24 @@ def reset_resolution(): asset = io.find_one({"name": asset, "type": "asset"}) try: - width = get_hierarchical_attr(asset, 'data.resolution_width', 1920) - height = get_hierarchical_attr(asset, 'data.resolution_height', 1080) - pixel_aspect = get_hierarchical_attr(asset, 'data.pixel_aspect', 1) - bbox = get_hierarchical_attr(asset, 'data.crop', "0.0.1920.1080") + width = asset.get('data', {}).get('resolution_width', 1920) + height = asset.get('data', {}).get('resolution_height', 1080) + pixel_aspect = asset.get('data', {}).get('pixel_aspect', 1) + bbox = asset.get('data', {}).get('crop', "0.0.1920.1080") - try: - x, y, r, t = bbox.split(".") - except Exception as e: - x = 0 - y = 0 - r = width - t = height - log.error("{}: {} \nFormat:Crop need to be set with dots, example: " - "0.0.1920.1080, /nSetting to default".format(__name__, e)) + if bbox not in "0.0.1920.1080": + try: + x, y, r, t = bbox.split(".") + except Exception as e: + x = 0 + y = 0 + r = width + t = height + bbox = None + log.error("{}: {} \nFormat:Crop need to be set with dots, example: " + "0.0.1920.1080, /nSetting to default".format(__name__, e)) + else: + bbox = None except KeyError: log.warning( @@ -462,25 +473,31 @@ def reset_resolution(): crnt_fmt_kargs = { "width": (check_format.width()), "height": (check_format.height()), - "x": int(check_format.x()), - "y": int(check_format.y()), - "r": int(check_format.r()), - "t": int(check_format.t()), "pixel_aspect": float(check_format.pixelAspect()) } + if bbox: + crnt_fmt_kargs.update({ + "x": int(check_format.x()), + "y": int(check_format.y()), + "r": int(check_format.r()), + "t": int(check_format.t()), + }) crnt_fmt_str = make_format_string(**crnt_fmt_kargs) log.info("crnt_fmt_str: {}".format(crnt_fmt_str)) new_fmt_kargs = { "width": int(width), "height": int(height), - "x": int(x), - "y": int(y), - "r": int(r), - "t": int(t), "pixel_aspect": float(pixel_aspect), "project_name": format_name } + if bbox: + new_fmt_kargs.update({ + "x": int(x), + "y": int(y), + "r": int(r), + "t": int(t), + }) new_fmt_str = make_format_string(**new_fmt_kargs) log.info("new_fmt_str: {}".format(new_fmt_str)) @@ -493,16 +510,22 @@ def reset_resolution(): def make_format_string(**args): - format_str = ( - "{width} " - "{height} " - "{x} " - "{y} " - "{r} " - "{t} " - "{pixel_aspect:.2f}".format(**args) - ) - return format_str + if args.get("r"): + return ( + "{width} " + "{height} " + "{x} " + "{y} " + "{r} " + "{t} " + "{pixel_aspect:.2f}".format(**args) + ) + else: + return ( + "{width} " + "{height} " + "{pixel_aspect:.2f}".format(**args) + ) def make_format(**args): From 8e52b5cbc397191a03278d1933c9250c1b04279f Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 9 Jul 2019 18:57:35 +0200 Subject: [PATCH 2/4] fix(pype): let integrator update already created version --- pype/plugins/global/publish/integrate_new.py | 32 ++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/pype/plugins/global/publish/integrate_new.py b/pype/plugins/global/publish/integrate_new.py index 61518eef63..3fa17af187 100644 --- a/pype/plugins/global/publish/integrate_new.py +++ b/pype/plugins/global/publish/integrate_new.py @@ -190,7 +190,21 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): data=version_data) self.log.debug("Creating version ...") - version_id = io.insert_one(version).inserted_id + existing_version = io.find_one({ + 'type': 'version', + 'parent': subset["_id"], + 'name': next_version + }) + if existing_version is None: + version_id = io.insert_one(version).inserted_id + else: + io.update_many({ + 'type': 'version', + 'parent': subset["_id"], + 'name': next_version + }, {'$set': version} + ) + version_id = existing_version['_id'] instance.data['version'] = version['name'] # Write to disk @@ -261,7 +275,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): src_collection = src_collections[0] # Assert that each member has identical suffix src_head = src_collection.format("{head}") - src_tail = ext = src_collection.format("{tail}") + src_tail = src_collection.format("{tail}") test_dest_files = list() for i in [1, 2]: @@ -284,12 +298,24 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): repre['published_path'] = dst_collection.format() + index_frame_start = None + if instance.data.get("frameStart"): + frame_start_padding = len(str( + instance.data.get("frameStart"))) + index_frame_start = instance.data.get("frameStart") + for i in src_collection.indexes: src_padding = src_collection.format("{padding}") % i src_file_name = "{0}{1}{2}".format( src_head, src_padding, src_tail) dst_padding = dst_collection.format("{padding}") % i + + if index_frame_start: + dst_padding = "%0{}d".format( + frame_start_padding) % index_frame_start + index_frame_start += 1 + dst = "{0}{1}{2}".format(dst_head, dst_padding, dst_tail) self.log.debug("destination: `{}`".format(dst)) src = os.path.join(stagingdir, src_file_name) @@ -321,7 +347,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): src = os.path.join(stagingdir, fname) anatomy_filled = anatomy.format(template_data) dst = os.path.normpath( - anatomy_filled[template_name]["path"]) + anatomy_filled[template_name]["path"]) instance.data["transfers"].append([src, dst]) From b8ddf3e3e0ef3e1be119fb07688fe87320d468fc Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 9 Jul 2019 18:58:10 +0200 Subject: [PATCH 3/4] fix(nks): improving first frame tag implementation --- .../nukestudio/publish/collect_hierarchy_context.py | 9 ++++++++- pype/plugins/nukestudio/publish/collect_plates.py | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pype/plugins/nukestudio/publish/collect_hierarchy_context.py b/pype/plugins/nukestudio/publish/collect_hierarchy_context.py index 1147a40600..67591a63ee 100644 --- a/pype/plugins/nukestudio/publish/collect_hierarchy_context.py +++ b/pype/plugins/nukestudio/publish/collect_hierarchy_context.py @@ -227,6 +227,8 @@ class CollectHierarchyContext(pyblish.api.ContextPlugin): # get custom attributes of the shot if instance.data.get("main"): + start_frame = instance.data.get("frameStart", 0) + in_info['custom_attributes'] = { 'handles': int(instance.data.get('handles')), 'handle_start': handle_start, @@ -237,7 +239,12 @@ class CollectHierarchyContext(pyblish.api.ContextPlugin): "edit_in": int(instance.data["startFrame"]), "edit_out": int(instance.data["endFrame"]) } - + if start_frame is not 0: + in_info['custom_attributes'].update({ + 'fstart': start_frame - handle_start, + 'fend': start_frame + ( + instance.data["endFrame"] - instance.data["startFrame"]) + handle_end + }) # adding SourceResolution if Tag was present s_res = instance.data.get("sourceResolution") if s_res and instance.data.get("main"): diff --git a/pype/plugins/nukestudio/publish/collect_plates.py b/pype/plugins/nukestudio/publish/collect_plates.py index 9cf6d10209..77ed4097c8 100644 --- a/pype/plugins/nukestudio/publish/collect_plates.py +++ b/pype/plugins/nukestudio/publish/collect_plates.py @@ -73,7 +73,7 @@ class CollectPlates(api.InstancePlugin): timeline_frame_start = timeline_in - handle_start timeline_frame_end = timeline_out + handle_end - frame_start = 1 + frame_start = instance.data.get("frameStart", 1) frame_end = frame_start + (data["sourceOut"] - data["sourceIn"]) data.update( @@ -186,7 +186,7 @@ class CollectPlatesData(api.InstancePlugin): "handles": handle_start, "handleStart": handle_start, "handleEnd": handle_end, - "sourceIn": source_in, + "sourceIn": source_in, "sourceOut": source_out, "startFrame": frame_start, "endFrame": frame_end, From ed0ed9aca72ae9877f7b983b5983a3a362b6c7f7 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 10 Jul 2019 11:23:04 +0200 Subject: [PATCH 4/4] fix(nks, nk): operation with handles --- pype/nuke/lib.py | 3 +++ pype/plugins/global/publish/integrate_new.py | 6 +++--- pype/plugins/nuke/create/create_write.py | 2 ++ .../plugins/nukestudio/publish/collect_handles.py | 2 +- .../publish/collect_hierarchy_context.py | 9 ++++----- pype/plugins/nukestudio/publish/collect_plates.py | 15 ++++++++++----- .../plugins/nukestudio/publish/collect_reviews.py | 8 +++++++- 7 files changed, 30 insertions(+), 15 deletions(-) diff --git a/pype/nuke/lib.py b/pype/nuke/lib.py index 247780855b..19781d6bf4 100644 --- a/pype/nuke/lib.py +++ b/pype/nuke/lib.py @@ -405,6 +405,9 @@ def reset_frame_range_handles(): log.info("_frameRange: {}".format(range)) log.info("frameRange: {}".format(vv['frame_range'].value())) + vv['frame_range'].setValue(range) + vv['frame_range_lock'].setValue(True) + def get_avalon_knob_data(node): import toml diff --git a/pype/plugins/global/publish/integrate_new.py b/pype/plugins/global/publish/integrate_new.py index 3fa17af187..2bb5b3bd60 100644 --- a/pype/plugins/global/publish/integrate_new.py +++ b/pype/plugins/global/publish/integrate_new.py @@ -299,10 +299,10 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): repre['published_path'] = dst_collection.format() index_frame_start = None - if instance.data.get("frameStart"): + if repre.get('startFrame'): frame_start_padding = len(str( - instance.data.get("frameStart"))) - index_frame_start = instance.data.get("frameStart") + repre.get('endFrame'))) + index_frame_start = repre.get('startFrame') for i in src_collection.indexes: src_padding = src_collection.format("{padding}") % i diff --git a/pype/plugins/nuke/create/create_write.py b/pype/plugins/nuke/create/create_write.py index 347a4a1fd2..ff1fde6638 100644 --- a/pype/plugins/nuke/create/create_write.py +++ b/pype/plugins/nuke/create/create_write.py @@ -29,6 +29,7 @@ class CreateWriteRender(avalon.nuke.Creator): family = "{}_write".format(preset) families = preset icon = "sign-out" + defaults = ["Main", "Mask"] def __init__(self, *args, **kwargs): super(CreateWriteRender, self).__init__(*args, **kwargs) @@ -72,6 +73,7 @@ class CreateWritePrerender(avalon.nuke.Creator): family = "{}_write".format(preset) families = preset icon = "sign-out" + defaults = ["Main", "Mask"] def __init__(self, *args, **kwargs): super(CreateWritePrerender, self).__init__(*args, **kwargs) diff --git a/pype/plugins/nukestudio/publish/collect_handles.py b/pype/plugins/nukestudio/publish/collect_handles.py index 03652989b8..104a60d02c 100644 --- a/pype/plugins/nukestudio/publish/collect_handles.py +++ b/pype/plugins/nukestudio/publish/collect_handles.py @@ -41,7 +41,7 @@ class CollectClipHandles(api.ContextPlugin): }) for instance in filtered_instances: - if not instance.data.get("main") and not instance.data.get("handleTag"): + if not instance.data.get("main") or not instance.data.get("handleTag"): self.log.debug("Synchronize handles on: `{}`".format( instance.data["name"])) name = instance.data["asset"] diff --git a/pype/plugins/nukestudio/publish/collect_hierarchy_context.py b/pype/plugins/nukestudio/publish/collect_hierarchy_context.py index 67591a63ee..bbae365fa6 100644 --- a/pype/plugins/nukestudio/publish/collect_hierarchy_context.py +++ b/pype/plugins/nukestudio/publish/collect_hierarchy_context.py @@ -198,7 +198,6 @@ class CollectHierarchyContext(pyblish.api.ContextPlugin): self.log.debug("__ s_asset_data: {}".format(s_asset_data)) name = instance.data["asset"] = s_asset_data["asset"] instance.data["parents"] = s_asset_data["parents"] - instance.data["parents"] = s_asset_data["parents"] instance.data["hierarchy"] = s_asset_data["hierarchy"] instance.data["tasks"] = s_asset_data["tasks"] @@ -233,17 +232,17 @@ class CollectHierarchyContext(pyblish.api.ContextPlugin): 'handles': int(instance.data.get('handles')), 'handle_start': handle_start, 'handle_end': handle_end, - 'fstart': int(instance.data["startFrame"] - handle_start), - 'fend': int(instance.data["endFrame"] + handle_end), + 'fstart': int(instance.data["startFrame"]), + 'fend': int(instance.data["endFrame"]), 'fps': instance.data["fps"], "edit_in": int(instance.data["startFrame"]), "edit_out": int(instance.data["endFrame"]) } if start_frame is not 0: in_info['custom_attributes'].update({ - 'fstart': start_frame - handle_start, + 'fstart': start_frame, 'fend': start_frame + ( - instance.data["endFrame"] - instance.data["startFrame"]) + handle_end + instance.data["endFrame"] - instance.data["startFrame"]) }) # adding SourceResolution if Tag was present s_res = instance.data.get("sourceResolution") diff --git a/pype/plugins/nukestudio/publish/collect_plates.py b/pype/plugins/nukestudio/publish/collect_plates.py index 77ed4097c8..abd02bfa78 100644 --- a/pype/plugins/nukestudio/publish/collect_plates.py +++ b/pype/plugins/nukestudio/publish/collect_plates.py @@ -41,7 +41,7 @@ class CollectPlates(api.InstancePlugin): data[key] = value data["family"] = family.lower() - data["families"] = ["ftrack"] + data["families"] = ["ftrack"] + instance.data["families"][1:] data["source"] = data["sourcePath"] subset = "" @@ -110,6 +110,9 @@ class CollectPlates(api.InstancePlugin): self.log.debug("Creating instance with name: {}".format(data["name"])) instance.context.create_instance(**data) + # # remove original instance + # instance.context.remove(instance) + class CollectPlatesData(api.InstancePlugin): """Collect plates""" @@ -217,9 +220,11 @@ class CollectPlatesData(api.InstancePlugin): padding=padding, ext=ext ) - start_frame = source_first_frame + self.log.debug("__ source_in_h: {}".format(source_in_h)) + self.log.debug("__ source_out_h: {}".format(source_out_h)) + start_frame = source_first_frame + source_in_h duration = source_out_h - source_in_h - end_frame = source_first_frame + duration + end_frame = start_frame + duration files = [file % i for i in range(start_frame, (end_frame + 1), 1)] except Exception as e: self.log.debug("Exception in file: {}".format(e)) @@ -276,8 +281,8 @@ class CollectPlatesData(api.InstancePlugin): 'stagingDir': staging_dir, 'name': ext, 'ext': ext, - 'startFrame': start_frame, - 'endFrame': end_frame, + 'startFrame': frame_start - handle_start, + 'endFrame': frame_end + handle_end, } instance.data["representations"].append(plates_representation) diff --git a/pype/plugins/nukestudio/publish/collect_reviews.py b/pype/plugins/nukestudio/publish/collect_reviews.py index 27cf79fa44..7b18c605a7 100644 --- a/pype/plugins/nukestudio/publish/collect_reviews.py +++ b/pype/plugins/nukestudio/publish/collect_reviews.py @@ -87,9 +87,15 @@ class CollectReviews(api.InstancePlugin): self.log.debug("Instance review: {}".format(rev_inst.data["name"])) + # getting file path parameters file_path = rev_inst.data.get("sourcePath") file_dir = os.path.dirname(file_path) file = os.path.basename(file_path) + ext = os.path.splitext(file)[-1][1:] + + # adding annotation to lablel + instance.data["label"] += " + review (.{})".format(ext) + instance.data["families"].append("review") # adding representation for review mov representation = { "files": file, @@ -101,7 +107,7 @@ class CollectReviews(api.InstancePlugin): "preview": True, "thumbnail": False, "name": "preview", - "ext": os.path.splitext(file)[-1][1:] + "ext": ext } instance.data["representations"].append(representation)