Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuke: Publish and load slate frame explicitly - AY-4055 #218

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions client/ayon_core/hosts/nuke/plugins/load/load_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ def load(self, context, name, namespace, options):
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"]
Expand Down Expand Up @@ -167,7 +179,9 @@ def load(self, context, name, namespace, options):
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:
Expand Down Expand Up @@ -402,14 +416,21 @@ def remove(self, container):
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 '''
Expand Down Expand Up @@ -466,18 +487,6 @@ def _make_retimes(self, parent_node, version_data):
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"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ def _render_slate_to_sequence(self, instance):
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):
Expand Down
22 changes: 22 additions & 0 deletions client/ayon_core/plugins/publish/extract_slate_data.py
Original file line number Diff line number Diff line change
@@ -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
Loading