From 1fdcd6bd6a8c502d0ee61758cd5d847589e57004 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Sun, 7 Jul 2019 21:44:36 +0200 Subject: [PATCH] feat(nks): handling handle_start/end workflow --- .../nukestudio/publish/collect_handles.py | 13 +++- .../publish/collect_hierarchy_context.py | 22 +++--- .../nukestudio/publish/collect_tag_handles.py | 72 +++++++++++-------- 3 files changed, 62 insertions(+), 45 deletions(-) diff --git a/pype/plugins/nukestudio/publish/collect_handles.py b/pype/plugins/nukestudio/publish/collect_handles.py index 0aa339d039..61ecfb7993 100644 --- a/pype/plugins/nukestudio/publish/collect_handles.py +++ b/pype/plugins/nukestudio/publish/collect_handles.py @@ -5,18 +5,18 @@ from pyblish import api class CollectClipHandles(api.ContextPlugin): """Collect Handles from all instanes and add to assetShared.""" - order = api.CollectorOrder + 0.1025 + order = api.CollectorOrder + 0.0121 label = "Collect Handles" hosts = ["nukestudio"] def process(self, context): assets_shared = context.data.get("assetsShared") - assert assets_shared, "Context data missing `assetsShared` key" # find all main types instances and add its handles to asset shared instances = context[:] filtered_instances = [] for instance in instances: + self.log.debug("_ instance.name: `{}`".format(instance.data["name"])) families = instance.data.get("families", []) families += [instance.data["family"]] if "clip" in families: @@ -28,6 +28,7 @@ class CollectClipHandles(api.ContextPlugin): handles = int(instance.data["handles"]) handle_start = int(instance.data["handleStart"]) handle_end = int(instance.data["handleEnd"]) + self.log.debug("_ instance.name: `{}`".format(instance.data["name"])) if instance.data.get("main"): name = instance.data["asset"] @@ -51,3 +52,11 @@ class CollectClipHandles(api.ContextPlugin): "handleStart", 0 ) instance.data["handleEnd"] = s_asset_data.get("handleEnd", 0) + self.log.debug("_ s_asset_data: `{}`".format( + s_asset_data)) + self.log.debug("_ instance.data[handles]: `{}`".format( + instance.data["handles"])) + self.log.debug("_ instance.data[handleStart]: `{}`".format( + instance.data["handleStart"])) + self.log.debug("_ instance.data[handleEnd]: `{}`".format( + instance.data["handleEnd"])) diff --git a/pype/plugins/nukestudio/publish/collect_hierarchy_context.py b/pype/plugins/nukestudio/publish/collect_hierarchy_context.py index c7c2647183..76d5126f9f 100644 --- a/pype/plugins/nukestudio/publish/collect_hierarchy_context.py +++ b/pype/plugins/nukestudio/publish/collect_hierarchy_context.py @@ -38,10 +38,6 @@ class CollectHierarchyInstance(pyblish.api.ContextPlugin): clip = instance.data["item"] asset = instance.data.get("asset") - # create asset_names conversion table - if not context.data.get("assetsShared"): - context.data["assetsShared"] = dict() - # build data for inner nukestudio project property data = { "sequence": ( @@ -193,12 +189,12 @@ class CollectHierarchyContext(pyblish.api.ContextPlugin): handle_start = int(instance.data["handleStart"] + handles) handle_end = int(instance.data["handleEnd"] + handles) - instance.data['startFrame'] = ( - instance.data["item"].timelineIn() - handle_start - ) - instance.data['endFrame'] = ( - instance.data["item"].timelineOut() + handle_end - ) + # instance.data['startFrame'] = ( + # instance.data["item"].timelineIn() - handle_start + # ) + # instance.data['endFrame'] = ( + # instance.data["item"].timelineOut() + handle_end + # ) # inject assetsShared to other plates types assets_shared = context.data.get("assetsShared") @@ -239,8 +235,10 @@ class CollectHierarchyContext(pyblish.api.ContextPlugin): # get custom attributes of the shot in_info['custom_attributes'] = { 'handles': int(instance.data.get('handles')), - 'fstart': int(instance.data["startFrame"]), - 'fend': int(instance.data["endFrame"]), + 'handle_start': handle_start, + 'handle_end': handle_end, + 'fstart': int(instance.data["startFrame"] - handle_start), + 'fend': int(instance.data["endFrame"] + handle_end), 'fps': context.data["framerate"], "edit_in": int(instance.data["startFrame"]), "edit_out": int(instance.data["endFrame"]) diff --git a/pype/plugins/nukestudio/publish/collect_tag_handles.py b/pype/plugins/nukestudio/publish/collect_tag_handles.py index 0752c7ef20..04134adf73 100644 --- a/pype/plugins/nukestudio/publish/collect_tag_handles.py +++ b/pype/plugins/nukestudio/publish/collect_tag_handles.py @@ -2,7 +2,7 @@ import json from pyblish import api -class CollectClipTagHandles(api.InstancePlugin): +class CollectClipTagHandles(api.ContextPlugin): """Collect Handles from selected track items.""" order = api.CollectorOrder + 0.012 @@ -10,38 +10,48 @@ class CollectClipTagHandles(api.InstancePlugin): hosts = ["nukestudio"] families = ['clip'] - def process(self, instance): - # gets tags - tags = instance.data["tags"] + def process(self, context): + assets_shared = context.data.get("assetsShared") + for instance in context[:]: + # gets tags + tags = instance.data["tags"] + assets_shared_a = assets_shared[instance.data["asset"]] + for t in tags: + t_metadata = dict(t["metadata"]) + t_family = t_metadata.get("tag.family", "") - for t in tags: - t_metadata = dict(t["metadata"]) - t_family = t_metadata.get("tag.family", "") + # gets only task family tags and collect labels + if "handles" in t_family: + # gets value of handles + t_value = int(t_metadata.get("tag.value", "")) - # gets only task family tags and collect labels - if "handles" in t_family: - # gets value of handles - t_value = int(t_metadata.get("tag.value", "")) + # gets arguments if there are any + t_args = t_metadata.get("tag.args", "") - # gets arguments if there are any - t_args = t_metadata.get("tag.args", "") + # distribute handles + if not t_args: + # add handles to both sides + instance.data['handles'] = t_value + self.log.info("Collected Handles: `{}`".format( + instance.data['handles'])) + else: + t_args = json.loads(t_args.replace("'", "\"")) + # add in start + if 'start' in t_args['where']: + instance.data["handleStart"] += t_value + self.log.info("Collected Handle Start: `{}`".format( + instance.data["handleStart"])) - # distribute handles - if not t_args: - # add handles to both sides - instance.data['handles'] = t_value - self.log.info("Collected Handles: `{}`".format( - instance.data['handles'])) - else: - t_args = json.loads(t_args.replace("'", "\"")) - # add in start - if 'start' in t_args['where']: - instance.data["handleStart"] += t_value - self.log.info("Collected Handle Start: `{}`".format( - instance.data["handleStart"])) + # add in end + if 'end' in t_args['where']: + instance.data["handleEnd"] += t_value + self.log.info("Collected Handle End: `{}`".format( + instance.data["handleEnd"])) - # add in end - if 'end' in t_args['where']: - instance.data["handleEnd"] += t_value - self.log.info("Collected Handle End: `{}`".format( - instance.data["handleEnd"])) + # adding handles to asset_shared on context + if instance.data.get("handleEnd"): + assets_shared_a["handleEnd"] = instance.data["handleEnd"] + if instance.data.get("handleStart"): + assets_shared_a["handleStart"] = instance.data["handleStart"] + if instance.data.get("handles"): + assets_shared_a["handles"] = instance.data["handles"]