nuke: getting testing values from script dirrectly

This commit is contained in:
Jakub Jezek 2022-07-25 17:57:13 +02:00
parent d3e982ebcf
commit b4b4725b57
No known key found for this signature in database
GPG key ID: 730D7C02726179A7

View file

@ -4,6 +4,9 @@ import pyblish.api
from openpype.client import get_project, get_asset_by_id, get_asset_by_name from openpype.client import get_project, get_asset_by_id, get_asset_by_name
from openpype.pipeline import legacy_io from openpype.pipeline import legacy_io
from openpype.pipeline import PublishXmlValidationError from openpype.pipeline import PublishXmlValidationError
from openpype.hosts.nuke.api.lib import (
get_avalon_knob_data
)
import nuke import nuke
@ -45,22 +48,32 @@ class ValidateScriptAttributes(pyblish.api.InstancePlugin):
asset_attributes asset_attributes
)) ))
handle_start = asset_attributes["handleStart"]
handle_end = asset_attributes["handleEnd"]
asset_attributes["fps"] = float("{0:.4f}".format( asset_attributes["fps"] = float("{0:.4f}".format(
asset_attributes["fps"])) asset_attributes["fps"]))
root = nuke.root() root = nuke.root()
knob_data = get_avalon_knob_data(root)
# Get frame range
first_frame = int(root["first_frame"].getValue())
last_frame = int(root["last_frame"].getValue())
handle_start = int(knob_data["handleStart"])
handle_end = int(knob_data["handleEnd"])
# Get format
_format = root["format"].value()
# Get values from nukescript # Get values from nukescript
script_attributes = { script_attributes = {
"handleStart": ctx_data["handleStart"], "handleStart": handle_start,
"handleEnd": ctx_data["handleEnd"], "handleEnd": handle_end,
"fps": float("{0:.4f}".format(ctx_data["fps"])), "fps": float("{0:.4f}".format(root['fps'].value())),
"frameStart": int(root["first_frame"].getValue()), "frameStart": first_frame + handle_start,
"frameEnd": int(root["last_frame"].getValue()), "frameEnd": last_frame - handle_end,
"resolutionWidth": ctx_data["resolutionWidth"], "resolutionWidth": _format.width(),
"resolutionHeight": ctx_data["resolutionHeight"], "resolutionHeight": _format.height(),
"pixelAspect": ctx_data["pixelAspect"] "pixelAspect": _format.pixelAspect()
} }
self.log.debug(pformat( self.log.debug(pformat(
script_attributes script_attributes