mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
fix(nks): supporting frameStart and changing plugin onto ContextPlugin
This commit is contained in:
parent
1fdcd6bd6a
commit
afe83dcf7a
1 changed files with 51 additions and 50 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue