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