mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
fix(nuke): plublish workfile handle_start/end was not correct
This commit is contained in:
parent
91bbf71218
commit
322ec3e3c8
5 changed files with 66 additions and 32 deletions
|
|
@ -539,7 +539,8 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
|
|||
|
||||
# Include optional data if present in
|
||||
optionals = [
|
||||
"startFrame", "endFrame", "step", "handles", "sourceHashes"
|
||||
"startFrame", "endFrame", "step", "handles",
|
||||
"handle_end", "handle_start", "sourceHashes"
|
||||
]
|
||||
for key in optionals:
|
||||
if key in instance.data:
|
||||
|
|
|
|||
|
|
@ -39,12 +39,14 @@ class LinkAsGroup(api.Loader):
|
|||
|
||||
precomp_name = context["representation"]["context"]["subset"]
|
||||
|
||||
self.log.info("versionData: {}\n".format(context["version"]["data"]))
|
||||
|
||||
# Set global in point to start frame (if in version.data)
|
||||
start = context["version"]["data"].get("startFrame", None)
|
||||
self.log.info("start: {}\n".format(start))
|
||||
|
||||
# add additional metadata from the version to imprint to Avalon knob
|
||||
add_keys = ["startFrame", "endFrame", "handles",
|
||||
"source", "author", "fps"]
|
||||
add_keys = ["startFrame", "endFrame", "handle_start", "handle_end", "source", "author", "fps"]
|
||||
|
||||
data_imprint = {
|
||||
"start_frame": start,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import pyblish.api
|
||||
|
||||
|
||||
class SelectCurrentFile(pyblish.api.ContextPlugin):
|
||||
class CollectCurrentFile(pyblish.api.ContextPlugin):
|
||||
"""Inject the current working file into context"""
|
||||
|
||||
order = pyblish.api.CollectorOrder - 0.5
|
||||
label = "Collect Current File"
|
||||
hosts = ["nuke"]
|
||||
|
||||
def process(self, context):
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import nuke
|
|||
import pyblish.api
|
||||
import os
|
||||
|
||||
import pype.api as pype
|
||||
|
||||
from avalon.nuke import (
|
||||
get_avalon_knob_data,
|
||||
add_publish_knob
|
||||
|
|
@ -24,16 +26,20 @@ class CollectWorkfile(pyblish.api.ContextPlugin):
|
|||
|
||||
family = "workfile"
|
||||
# creating instances per write node
|
||||
file_path = root['name'].value()
|
||||
file_path = context.data["currentFile"]
|
||||
staging_dir = os.path.dirname(file_path)
|
||||
base_name = os.path.basename(file_path)
|
||||
subset = "{0}_{1}".format(os.getenv("AVALON_TASK", None), family)
|
||||
|
||||
# get version string
|
||||
version = pype.get_version_from_path(base_name)
|
||||
|
||||
# Get frame range
|
||||
first_frame = int(root["first_frame"].getValue())
|
||||
last_frame = int(root["last_frame"].getValue())
|
||||
|
||||
handle_start = int(knob_data["handle_start"])
|
||||
handle_end = int(knob_data["handle_end"])
|
||||
handle_start = int(knob_data.get("handle_start", 0))
|
||||
handle_end = int(knob_data.get("handle_end", 0))
|
||||
|
||||
# Get format
|
||||
format = root['format'].value()
|
||||
|
|
@ -45,23 +51,47 @@ class CollectWorkfile(pyblish.api.ContextPlugin):
|
|||
instance = context.create_instance(subset)
|
||||
instance.add(root)
|
||||
|
||||
instance.data.update({
|
||||
"subset": subset,
|
||||
script_data = {
|
||||
"asset": os.getenv("AVALON_ASSET", None),
|
||||
"label": base_name,
|
||||
"name": base_name,
|
||||
"startFrame": first_frame,
|
||||
"endFrame": last_frame,
|
||||
"version": version,
|
||||
"startFrame": first_frame + handle_start,
|
||||
"endFrame": last_frame - handle_end,
|
||||
"resolution_width": resolution_width,
|
||||
"resolution_height": resolution_height,
|
||||
"pixel_aspect": pixel_aspect,
|
||||
"publish": root.knob('publish').value(),
|
||||
"family": family,
|
||||
"representation": "nk",
|
||||
|
||||
# backward compatibility
|
||||
"handles": handle_start,
|
||||
|
||||
"handle_start": handle_start,
|
||||
"handle_end": handle_end,
|
||||
"step": 1,
|
||||
"fps": int(root['fps'].value()),
|
||||
"fps": root['fps'].value(),
|
||||
}
|
||||
context.data.update(script_data)
|
||||
|
||||
# creating instance data
|
||||
instance.data.update({
|
||||
"subset": subset,
|
||||
"label": base_name,
|
||||
"name": base_name,
|
||||
"publish": root.knob('publish').value(),
|
||||
"family": family,
|
||||
"representations": list()
|
||||
})
|
||||
|
||||
# adding basic script data
|
||||
instance.data.update(script_data)
|
||||
|
||||
# creating representation
|
||||
representation = {
|
||||
'name': 'nk',
|
||||
'ext': 'nk',
|
||||
'files': base_name,
|
||||
"stagingDir": staging_dir,
|
||||
}
|
||||
|
||||
instance.data["representations"].append(representation)
|
||||
|
||||
self.log.info('Publishing script version')
|
||||
context.data["instances"].append(instance)
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ class ValidateScript(pyblish.api.InstancePlugin):
|
|||
hosts = ["nuke"]
|
||||
|
||||
def process(self, instance):
|
||||
instance_data = instance.data
|
||||
asset_name = instance_data["asset"]
|
||||
ctx_data = instance.context.data
|
||||
asset_name = ctx_data["asset"]
|
||||
|
||||
asset = io.find_one({
|
||||
"type": "asset",
|
||||
|
|
@ -66,19 +66,19 @@ class ValidateScript(pyblish.api.InstancePlugin):
|
|||
handle_end = asset_attributes["handle_end"]
|
||||
|
||||
# Set frame range with handles
|
||||
asset_attributes["fstart"] -= handle_start
|
||||
asset_attributes["fend"] += handle_end
|
||||
# asset_attributes["fstart"] -= handle_start
|
||||
# asset_attributes["fend"] += handle_end
|
||||
|
||||
# Get values from nukescript
|
||||
script_attributes = {
|
||||
"handle_start": instance_data["handle_start"],
|
||||
"handle_end": instance_data["handle_end"],
|
||||
"fps": instance_data["fps"],
|
||||
"fstart": instance_data["startFrame"],
|
||||
"fend": instance_data["endFrame"],
|
||||
"resolution_width": instance_data["resolution_width"],
|
||||
"resolution_height": instance_data["resolution_height"],
|
||||
"pixel_aspect": instance_data["pixel_aspect"]
|
||||
"handle_start": ctx_data["handle_start"],
|
||||
"handle_end": ctx_data["handle_end"],
|
||||
"fps": ctx_data["fps"],
|
||||
"fstart": ctx_data["startFrame"],
|
||||
"fend": ctx_data["endFrame"],
|
||||
"resolution_width": ctx_data["resolution_width"],
|
||||
"resolution_height": ctx_data["resolution_height"],
|
||||
"pixel_aspect": ctx_data["pixel_aspect"]
|
||||
}
|
||||
|
||||
# Compare asset's values Nukescript X Database
|
||||
|
|
@ -95,10 +95,10 @@ class ValidateScript(pyblish.api.InstancePlugin):
|
|||
# Alert user that handles are set if Frame start/end not match
|
||||
if (
|
||||
(("fstart" in not_matching) or ("fend" in not_matching)) and
|
||||
(handles > 0)
|
||||
((handle_start > 0) or (handle_end > 0))
|
||||
):
|
||||
handles = str(handles).replace(".0", "")
|
||||
msg += " (handles are set to {})".format(handles)
|
||||
msg += " (`handle_start` are set to {})".format(handle_start)
|
||||
msg += " (`handle_end` are set to {})".format(handle_end)
|
||||
message = msg.format(", ".join(not_matching))
|
||||
raise ValueError(message)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue