nuke reducing nodes and moving args to precollect

This commit is contained in:
Jakub Jezek 2021-01-20 14:21:17 +01:00
parent 8699e274a9
commit 5eac2364cc
No known key found for this signature in database
GPG key ID: C4B96E101D2A47F3
7 changed files with 26 additions and 134 deletions

View file

@ -1,14 +0,0 @@
import pyblish.api
class CollectHost(pyblish.api.ContextPlugin):
"""Inject the host into context"""
order = pyblish.api.CollectorOrder
label = "Collect Host"
hosts = ["nuke"]
def process(self, context):
import pyblish.api
context.data["host"] = pyblish.api.current_host()

View file

@ -1,13 +0,0 @@
import pyblish.api
class CollectHostVersion(pyblish.api.ContextPlugin):
"""Inject the hosts version into context"""
order = pyblish.api.CollectorOrder
label = "Collect Host Version"
hosts = ["nuke"]
def process(self, context):
import nuke
context.data["hostVersion"] = nuke.NUKE_VERSION_STRING

View file

@ -1,30 +0,0 @@
import toml
import nuke
import pyblish.api
class CollectReadLegacy(pyblish.api.ContextPlugin):
"""Collect legacy read nodes."""
order = pyblish.api.CollectorOrder
label = "Collect Read Legacy"
hosts = ["nuke", "nukeassist"]
def process(self, context):
for node in nuke.allNodes():
if node.Class() != "Read":
continue
if "avalon" not in node.knobs().keys():
continue
if not toml.loads(node["avalon"].value()):
return
instance = context.create_instance(
node.name(), family="read.legacy"
)
instance.append(node)

View file

@ -1,52 +0,0 @@
import pyblish.api
import pype.api
from avalon import io, api
import nuke
class CollectReview(pyblish.api.InstancePlugin):
"""Collect review instance from rendered frames
"""
order = pyblish.api.CollectorOrder + 0.3
label = "Collect Review"
hosts = ["nuke"]
families = ["render", "render.local", "render.farm"]
def process(self, instance):
node = instance[0]
if "review" not in node.knobs():
knob = nuke.Boolean_Knob("review", "Review")
knob.setValue(True)
node.addKnob(knob)
if not node["review"].value():
return
# * Add audio to instance if exists.
# Find latest versions document
version_doc = pype.api.get_latest_version(
instance.context.data["assetEntity"]["name"], "audioMain"
)
repre_doc = None
if version_doc:
# Try to find it's representation (Expected there is only one)
repre_doc = io.find_one(
{"type": "representation", "parent": version_doc["_id"]}
)
# Add audio to instance if representation was found
if repre_doc:
instance.data["audio"] = [{
"offset": 0,
"filename": api.get_representation_path(repre_doc)
}]
instance.data["families"].append("review")
instance.data['families'].append('ftrack')
self.log.info("Review collected: `{}`".format(instance))
self.log.debug("__ instance.data: `{}`".format(instance.data))

View file

@ -1,14 +0,0 @@
import nuke
import pyblish.api
class CollectSelection(pyblish.api.ContextPlugin):
"""Collect selection."""
order = pyblish.api.CollectorOrder
label = "Collect Selection of Nodes"
hosts = ["nuke"]
def process(self, context):
context.data["selection"] = nuke.selectedNodes()

View file

@ -1,7 +1,7 @@
import nuke
import pyblish.api
import os
import pype.api as pype
from avalon.nuke import lib as anlib
reload(anlib)
@ -62,7 +62,11 @@ class CollectWorkfile(pyblish.api.ContextPlugin):
"step": 1,
"fps": root['fps'].value(),
"currentFile": current_file
"currentFile": current_file,
"version": pype.get_version_from_path(current_file),
"host": pyblish.api.current_host(),
"hostVersion": nuke.NUKE_VERSION_STRING
}
context.data.update(script_data)

View file

@ -2,6 +2,7 @@ import os
import nuke
import pyblish.api
import pype.api as pype
from avalon import io, api
@pyblish.api.log
@ -40,7 +41,6 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
# Get frame range
handle_start = instance.context.data["handleStart"]
handle_end = instance.context.data["handleEnd"]
current_file = instance.context.data["currentFile"]
first_frame = int(nuke.root()["first_frame"].getValue())
last_frame = int(nuke.root()["last_frame"].getValue())
frame_length = int(last_frame - first_frame + 1)
@ -55,14 +55,6 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
output_dir = os.path.dirname(path)
self.log.debug('output dir: {}'.format(output_dir))
if not next((f for f in families
if "prerender" in f),
None) and self.sync_workfile_version:
# get version to instance for integration
instance.data['version'] = pype.get_version_from_path(current_file)
self.log.debug('Write Version: %s' % instance.data('version'))
# create label
name = node.name()
# Include start and end render frame in label
@ -158,6 +150,25 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
"families": []
})
# * Add audio to instance if exists.
# Find latest versions document
version_doc = pype.get_latest_version(
instance.data["asset"], "audioMain"
)
repre_doc = None
if version_doc:
# Try to find it's representation (Expected there is only one)
repre_doc = io.find_one(
{"type": "representation", "parent": version_doc["_id"]}
)
# Add audio to instance if representation was found
if repre_doc:
instance.data["audio"] = [{
"offset": 0,
"filename": api.get_representation_path(repre_doc)
}]
self.log.debug("families: {}".format(families))
self.log.debug("instance.data: {}".format(instance.data))