mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
- script is validated. - added format in collect script plugin
This commit is contained in:
parent
477528b565
commit
7dbc0376f6
2 changed files with 115 additions and 0 deletions
|
|
@ -34,6 +34,12 @@ class CollectScript(pyblish.api.ContextPlugin):
|
|||
first_frame = int(root["first_frame"].getValue())
|
||||
last_frame = int(root["last_frame"].getValue())
|
||||
|
||||
# Get format
|
||||
format = root['format'].value()
|
||||
resolution_width = format.width()
|
||||
resolution_height = format.height()
|
||||
pixel_aspect = format.pixelAspect()
|
||||
|
||||
# Create instance
|
||||
instance = context.create_instance(subset)
|
||||
instance.add(root)
|
||||
|
|
@ -45,6 +51,9 @@ class CollectScript(pyblish.api.ContextPlugin):
|
|||
"name": base_name,
|
||||
"startFrame": first_frame,
|
||||
"endFrame": last_frame,
|
||||
"resolution_width": resolution_width,
|
||||
"resolution_height": resolution_height,
|
||||
"pixel_aspect": pixel_aspect,
|
||||
"publish": root.knob('publish').value(),
|
||||
"family": family,
|
||||
"representation": "nk",
|
||||
|
|
|
|||
106
pype/plugins/nuke/publish/validate_script.py
Normal file
106
pype/plugins/nuke/publish/validate_script.py
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import pyblish.api
|
||||
from avalon import io
|
||||
|
||||
|
||||
@pyblish.api.log
|
||||
class ValidateScript(pyblish.api.InstancePlugin):
|
||||
""" Validates file output. """
|
||||
|
||||
order = pyblish.api.ValidatorOrder + 0.1
|
||||
families = ["nukescript"]
|
||||
label = "Check nukescript settings"
|
||||
hosts = ["nuke"]
|
||||
|
||||
def process(self, instance):
|
||||
instance_data = instance.data
|
||||
asset_name = instance_data["asset"]
|
||||
|
||||
asset = io.find_one({
|
||||
"type": "asset",
|
||||
"name": asset_name
|
||||
})
|
||||
asset_data = asset["data"]
|
||||
|
||||
# These attributes will be checked
|
||||
attributes = [
|
||||
"fps", "fstart", "fend",
|
||||
"resolution_width", "resolution_height", "pixel_aspect"
|
||||
]
|
||||
|
||||
# Value of these attributes can be found on parents
|
||||
hierarchical_attributes = ["fps"]
|
||||
|
||||
missing_attributes = []
|
||||
asset_attributes = {}
|
||||
for attr in attributes:
|
||||
if attr in asset_data:
|
||||
asset_attributes[attr] = asset_data[attr]
|
||||
|
||||
elif attr in hierarchical_attributes:
|
||||
# Try to find fps on parent
|
||||
parent = asset['parent']
|
||||
if asset_data['visualParent'] is not None:
|
||||
parent = asset_data['visualParent']
|
||||
|
||||
value = self.check_parent_hierarchical(parent, attr)
|
||||
if value is None:
|
||||
missing_attributes.append(attr)
|
||||
else:
|
||||
asset_attributes[attr] = value
|
||||
|
||||
else:
|
||||
missing_attributes.append(attr)
|
||||
|
||||
# Raise error if attributes weren't found on asset in database
|
||||
if len(missing_attributes) > 0:
|
||||
atr = ", ".join(missing_attributes)
|
||||
msg = 'Missing attributes "{}" in asset "{}"'
|
||||
message = msg.format(atr, asset_name)
|
||||
raise ValueError(message)
|
||||
|
||||
# Get handles from database, Default is 0 (if not found)
|
||||
handles = 0
|
||||
if "handles" in asset_data:
|
||||
handles = asset_data["handles"]
|
||||
|
||||
# Set frame range with handles
|
||||
asset_attributes["fstart"] -= handles
|
||||
asset_attributes["fend"] += handles
|
||||
|
||||
# Get values from nukescript
|
||||
script_attributes = {
|
||||
"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"]
|
||||
}
|
||||
|
||||
# Compare asset's values Nukescript X Database
|
||||
not_matching = []
|
||||
for attr in attributes:
|
||||
if asset_attributes[attr] != script_attributes[attr]:
|
||||
not_matching.append(attr)
|
||||
|
||||
# Raise error if not matching
|
||||
if len(not_matching) > 0:
|
||||
msg = "Attributes '{}' aro 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
|
||||
(handles > 0)
|
||||
):
|
||||
handles = str(handles).replace(".0", "")
|
||||
msg += " (handles are set to {})".format(handles)
|
||||
message = msg.format(", ".join(not_matching))
|
||||
raise ValueError(message)
|
||||
|
||||
def check_parent_hierarchical(self, entityId, attr):
|
||||
if entityId is None:
|
||||
return None
|
||||
entity = io.find_one({"_id": entityId})
|
||||
if attr in entity['data']:
|
||||
return entity['data'][attr]
|
||||
else:
|
||||
return self.check_parent_hierarchical(entity['parent'], attr)
|
||||
Loading…
Add table
Add a link
Reference in a new issue