fix(nuke): nukescript to workfile fix, handles_start/end workflow improvment

This commit is contained in:
Jakub Jezek 2019-07-11 13:58:47 +02:00
parent 8619d8838b
commit e49aaab9f4
6 changed files with 136 additions and 28 deletions

View file

@ -1,26 +1,28 @@
from avalon import api, io
import nuke
import pyblish.api
import os
from avalon.nuke.lib import (
add_publish_knob,
add_avalon_tab_knob
from avalon.nuke import (
get_avalon_knob_data,
add_publish_knob
)
class CollectScript(pyblish.api.ContextPlugin):
class CollectWorkfile(pyblish.api.ContextPlugin):
"""Publish current script version."""
order = pyblish.api.CollectorOrder + 0.1
label = "Collect Script to publish"
label = "Collect Workfile"
hosts = ['nuke']
def process(self, context):
root = nuke.root()
add_avalon_tab_knob(root)
knob_data = get_avalon_knob_data(root)
add_publish_knob(root)
family = "nukescript"
family = "workfile"
# creating instances per write node
file_path = root['name'].value()
base_name = os.path.basename(file_path)
@ -30,6 +32,9 @@ class CollectScript(pyblish.api.ContextPlugin):
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"])
# Get format
format = root['format'].value()
resolution_width = format.width()
@ -53,7 +58,8 @@ class CollectScript(pyblish.api.ContextPlugin):
"publish": root.knob('publish').value(),
"family": family,
"representation": "nk",
"handles": context.data['handles'],
"handle_start": handle_start,
"handle_end": handle_end,
"step": 1,
"fps": int(root['fps'].value()),
})

View file

@ -12,7 +12,7 @@ class ExtractScript(pype.api.Extractor):
order = pyblish.api.ExtractorOrder - 0.05
optional = True
hosts = ['nuke']
families = ["nukescript"]
families = ["workfile"]
def process(self, instance):
self.log.debug("instance extracting: {}".format(instance.data))
@ -28,7 +28,7 @@ class ExtractScript(pype.api.Extractor):
if "representations" not in instance.data:
instance.data["representations"] = []
representation = {
'name': 'nk',
'ext': '.nk',

View file

@ -7,7 +7,7 @@ class ValidateScript(pyblish.api.InstancePlugin):
""" Validates file output. """
order = pyblish.api.ValidatorOrder + 0.1
families = ["nukescript"]
families = ["workfile"]
label = "Check script settings"
hosts = ["nuke"]
@ -24,11 +24,11 @@ class ValidateScript(pyblish.api.InstancePlugin):
# These attributes will be checked
attributes = [
"fps", "fstart", "fend",
"resolution_width", "resolution_height", "pixel_aspect", "handles"
"resolution_width", "resolution_height", "pixel_aspect", "handle_start", "handle_end"
]
# Value of these attributes can be found on parents
hierarchical_attributes = ["fps", "resolution_width", "resolution_height", "pixel_aspect", "handles"]
hierarchical_attributes = ["fps", "resolution_width", "resolution_height", "pixel_aspect", "handle_start", "handle_end"]
missing_attributes = []
asset_attributes = {}
@ -58,17 +58,21 @@ class ValidateScript(pyblish.api.InstancePlugin):
raise ValueError(message)
# Get handles from database, Default is 0 (if not found)
handles = 0
if "handles" in asset_attributes:
handles = asset_attributes["handles"]
handle_start = 0
handle_end = 0
if "handle_start" in asset_attributes:
handle_start = asset_attributes["handle_start"]
if "handle_end" in asset_attributes:
handle_end = asset_attributes["handle_end"]
# Set frame range with handles
asset_attributes["fstart"] -= handles
asset_attributes["fend"] += handles
asset_attributes["fstart"] -= handle_start
asset_attributes["fend"] += handle_end
# Get values from nukescript
script_attributes = {
"handles": handles,
"handle_start": instance_data["handle_start"],
"handle_end": instance_data["handle_end"],
"fps": instance_data["fps"],
"fstart": instance_data["startFrame"],
"fend": instance_data["endFrame"],
@ -87,7 +91,7 @@ class ValidateScript(pyblish.api.InstancePlugin):
# Raise error if not matching
if len(not_matching) > 0:
msg = "Attributes '{}' aro not set correctly"
msg = "Attributes '{}' are not set correctly"
# Alert user that handles are set if Frame start/end not match
if (
(("fstart" in not_matching) or ("fend" in not_matching)) and