From afe83dcf7a99193356255cede8ff25a57a904d49 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Sun, 7 Jul 2019 21:45:24 +0200 Subject: [PATCH] fix(nks): supporting `frameStart` and changing plugin onto ContextPlugin --- .../nukestudio/publish/collect_shots.py | 101 +++++++++--------- 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/pype/plugins/nukestudio/publish/collect_shots.py b/pype/plugins/nukestudio/publish/collect_shots.py index 8cf02ff764..8e02f4d27a 100644 --- a/pype/plugins/nukestudio/publish/collect_shots.py +++ b/pype/plugins/nukestudio/publish/collect_shots.py @@ -1,7 +1,7 @@ from pyblish import api -class CollectShots(api.InstancePlugin): +class CollectShots(api.ContextPlugin): """Collect Shot from Clip.""" # Run just before CollectClipSubsets @@ -10,61 +10,62 @@ class CollectShots(api.InstancePlugin): hosts = ["nukestudio"] families = ["clip"] - def process(self, instance): - # Exclude non-tagged instances. - tagged = False - for tag in instance.data["tags"]: - if tag["name"].lower() == "hierarchy": - tagged = True + def process(self, context): + for instance in context[:]: + # Exclude non-tagged instances. + tagged = False + for tag in instance.data["tags"]: + if tag["name"].lower() == "hierarchy": + tagged = True - if not tagged: - self.log.debug( - "Skipping \"{}\" because its not tagged with " - "\"Hierarchy\"".format(instance) + if not tagged: + self.log.debug( + "Skipping \"{}\" because its not tagged with " + "\"Hierarchy\"".format(instance) + ) + continue + + # Collect data. + data = {} + for key, value in instance.data.iteritems(): + data[key] = value + + data["family"] = "shot" + data["families"] = [] + data["frameStart"] = instance.data.get("frameStart", 1) + + data["label"] += " - tasks: {} - assetbuilds: {}".format( + data["tasks"], [x["name"] for x in data.get("assetbuilds", [])] ) - return - # Collect data. - data = {} - for key, value in instance.data.iteritems(): - data[key] = value + # Get handles. + data["handleStart"] = instance.data["handleStart"] + data["handleStart"] += data["handles"] + data["handleEnd"] = instance.data["handleEnd"] + data["handles"] - data["family"] = "shot" - data["families"] = [] - data["frameStart"] = 1 + # Frame-ranges with handles. + data["sourceInH"] = data["sourceIn"] - data["handleStart"] + data["sourceOutH"] = data["sourceOut"] + data["handleEnd"] - data["label"] += " - tasks: {} - assetbuilds: {}".format( - data["tasks"], [x["name"] for x in data.get("assetbuilds", [])] - ) + # Get timeline frames. + data["timelineIn"] = int(data["item"].timelineIn()) + data["timelineOut"] = int(data["item"].timelineOut()) - # Get handles. - data["handleStart"] = instance.data["handleStart"] - data["handleStart"] += data["handles"] - data["handleEnd"] = instance.data["handleEnd"] + data["handles"] + # Frame-ranges with handles. + data["timelineInHandles"] = data["timelineIn"] + data["timelineInHandles"] -= data["handleStart"] + data["timelineOutHandles"] = data["timelineOut"] + data["timelineOutHandles"] += data["handleEnd"] - # Frame-ranges with handles. - data["sourceInH"] = data["sourceIn"] - data["handleStart"] - data["sourceOutH"] = data["sourceOut"] + data["handleEnd"] + # Creating comp frame range. + data["endFrame"] = ( + data["frameStart"] + (data["sourceOut"] - data["sourceIn"]) + ) - # Get timeline frames. - data["timelineIn"] = int(data["item"].timelineIn()) - data["timelineOut"] = int(data["item"].timelineOut()) + # Get fps. + sequence = instance.context.data["activeSequence"] + data["fps"] = sequence.framerate() - # Frame-ranges with handles. - data["timelineInHandles"] = data["timelineIn"] - data["timelineInHandles"] -= data["handleStart"] - data["timelineOutHandles"] = data["timelineOut"] - data["timelineOutHandles"] += data["handleEnd"] - - # Creating comp frame range. - data["endFrame"] = ( - data["frameStart"] + (data["sourceOut"] - data["sourceIn"]) - ) - - # Get fps. - sequence = instance.context.data["activeSequence"] - data["fps"] = sequence.framerate() - - # Create instance. - self.log.debug("Creating instance with: {}".format(data)) - instance.context.create_instance(**data) + # Create instance. + self.log.debug("Creating instance with: {}".format(data)) + instance.context.create_instance(**data)