Merge pull request #218 from ynput/enhancement/AY-4055_Explicit-slate-frame-metadata

Nuke: Publish and load slate frame explicitly - AY-4055
This commit is contained in:
Jakub Ježek 2024-04-09 14:37:04 +02:00 committed by GitHub
commit ad06217ba0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 50 additions and 15 deletions

View file

@ -130,6 +130,18 @@ class LoadClip(plugin.NukeLoader):
first = 1
last = first + duration
# If a slate is present, the frame range is 1 frame longer for movies,
# but file sequences its the first frame that is 1 frame lower.
slate_frames = repre_entity["data"].get("slateFrames", 0)
extension = "." + repre_entity["context"]["ext"]
if extension in VIDEO_EXTENSIONS:
last += slate_frames
files_count = len(repre_entity["files"])
if extension in IMAGE_EXTENSIONS and files_count != 1:
first -= slate_frames
# Fallback to folder name when namespace is None
if namespace is None:
namespace = context["folder"]["name"]
@ -167,7 +179,9 @@ class LoadClip(plugin.NukeLoader):
repre_entity
)
self._set_range_to_node(read_node, first, last, start_at_workfile)
self._set_range_to_node(
read_node, first, last, start_at_workfile, slate_frames
)
version_name = version_entity["version"]
if version_name < 0:
@ -402,14 +416,21 @@ class LoadClip(plugin.NukeLoader):
for member in members:
nuke.delete(member)
def _set_range_to_node(self, read_node, first, last, start_at_workfile):
def _set_range_to_node(
self, read_node, first, last, start_at_workfile, slate_frames=0
):
read_node['origfirst'].setValue(int(first))
read_node['first'].setValue(int(first))
read_node['origlast'].setValue(int(last))
read_node['last'].setValue(int(last))
# set start frame depending on workfile or version
self._loader_shift(read_node, start_at_workfile)
if start_at_workfile:
read_node['frame_mode'].setValue("start at")
start_frame = self.script_start - slate_frames
read_node['frame'].setValue(str(start_frame))
def _make_retimes(self, parent_node, version_data):
''' Create all retime and timewarping nodes with copied animation '''
@ -466,18 +487,6 @@ class LoadClip(plugin.NukeLoader):
for i, n in enumerate(dependent_nodes):
last_node.setInput(i, n)
def _loader_shift(self, read_node, workfile_start=False):
""" Set start frame of read node to a workfile start
Args:
read_node (nuke.Node): The nuke's read node
workfile_start (bool): set workfile start frame if true
"""
if workfile_start:
read_node['frame_mode'].setValue("start at")
read_node['frame'].setValue(str(self.script_start))
def _get_node_name(self, context):
folder_entity = context["folder"]
product_name = context["product"]["name"]

View file

@ -300,6 +300,10 @@ class ExtractSlateFrame(publish.Extractor):
self.log.debug(
"__ matching_repre: {}".format(pformat(matching_repre)))
data = matching_repre.get("data", {})
data["slateFrames"] = 1
matching_repre["data"] = data
self.log.info("Added slate frame to representation files")
def add_comment_slate_node(self, instance, node):

View file

@ -0,0 +1,22 @@
import pyblish.api
from ayon_core.pipeline import publish
class ExtractSlateData(publish.Extractor):
"""Add slate data for integration."""
label = "Slate Data"
# Offset from ExtractReviewSlate and ExtractGenerateSlate.
order = pyblish.api.ExtractorOrder + 0.49
families = ["slate", "review"]
hosts = ["nuke", "shell"]
def process(self, instance):
for representation in instance.data.get("representations", []):
if "slate-frame" not in representation.get("tags", []):
continue
data = representation.get("data", {})
data["slateFrames"] = 1
representation["data"] = data