mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
nuke plugins to precollect stage
This commit is contained in:
parent
398bc687d4
commit
c7e331b786
5 changed files with 44 additions and 41 deletions
|
|
@ -1,19 +0,0 @@
|
|||
import pyblish.api
|
||||
|
||||
|
||||
class CollectCurrentFile(pyblish.api.ContextPlugin):
|
||||
"""Inject the current working file into context"""
|
||||
|
||||
order = pyblish.api.CollectorOrder - 0.5
|
||||
label = "Collect Current File"
|
||||
hosts = ["nuke"]
|
||||
|
||||
def process(self, context):
|
||||
import os
|
||||
import nuke
|
||||
current_file = nuke.root().name()
|
||||
|
||||
normalised = os.path.normpath(current_file)
|
||||
|
||||
context.data["current_file"] = normalised
|
||||
context.data["currentFile"] = normalised
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
import pyblish.api
|
||||
from avalon.nuke import lib as anlib
|
||||
from pype.hosts.nuke import lib as pnlib
|
||||
from pype.hosts.nuke.api import lib as pnlib
|
||||
import pype
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from avalon.nuke import lib as anlib
|
|||
class PreCollectNukeInstances(pyblish.api.ContextPlugin):
|
||||
"""Collect all nodes with Avalon knob."""
|
||||
|
||||
order = pyblish.api.CollectorOrder - 0.6
|
||||
order = pyblish.api.CollectorOrder - 0.59
|
||||
label = "Pre-collect Instances"
|
||||
hosts = ["nuke", "nukeassist"]
|
||||
|
||||
|
|
@ -36,7 +36,6 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin):
|
|||
self.log.warning(E)
|
||||
|
||||
# get data from avalon knob
|
||||
self.log.debug("node[name]: {}".format(node['name'].value()))
|
||||
avalon_knob_data = anlib.get_avalon_knob_data(
|
||||
node, ["avalon:", "ak:"])
|
||||
|
||||
|
|
@ -69,6 +68,12 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin):
|
|||
instance = context.create_instance(subset)
|
||||
instance.append(node)
|
||||
|
||||
# get review knob value
|
||||
review = False
|
||||
if "review" in node.knobs():
|
||||
review = node["review"].value()
|
||||
families.append("review")
|
||||
|
||||
# Add all nodes in group instances.
|
||||
if node.Class() == "Group":
|
||||
# only alter families for render family
|
||||
|
|
@ -119,10 +124,15 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin):
|
|||
"resolutionWidth": resolution_width,
|
||||
"resolutionHeight": resolution_height,
|
||||
"pixelAspect": pixel_aspect,
|
||||
"review": review
|
||||
|
||||
})
|
||||
self.log.info("collected instance: {}".format(instance.data))
|
||||
instances.append(instance)
|
||||
|
||||
context.data["instances"] = instances
|
||||
# create instances in context data if not are created yet
|
||||
if not context.data.get("instances"):
|
||||
context.data["instances"] = list()
|
||||
|
||||
context.data["instances"].extend(instances)
|
||||
self.log.debug("context: {}".format(context))
|
||||
|
|
|
|||
|
|
@ -2,32 +2,31 @@ import nuke
|
|||
import pyblish.api
|
||||
import os
|
||||
|
||||
from avalon.nuke import (
|
||||
get_avalon_knob_data,
|
||||
add_publish_knob
|
||||
)
|
||||
from avalon.nuke import lib as anlib
|
||||
reload(anlib)
|
||||
|
||||
|
||||
class CollectWorkfile(pyblish.api.ContextPlugin):
|
||||
"""Collect current script for publish."""
|
||||
|
||||
order = pyblish.api.CollectorOrder + 0.1
|
||||
label = "Collect Workfile"
|
||||
order = pyblish.api.CollectorOrder - 0.60
|
||||
label = "Pre-collect Workfile"
|
||||
hosts = ['nuke']
|
||||
|
||||
def process(self, context):
|
||||
root = nuke.root()
|
||||
|
||||
knob_data = get_avalon_knob_data(root)
|
||||
current_file = os.path.normpath(nuke.root().name())
|
||||
|
||||
add_publish_knob(root)
|
||||
knob_data = anlib.get_avalon_knob_data(root)
|
||||
|
||||
anlib.add_publish_knob(root)
|
||||
|
||||
family = "workfile"
|
||||
task = os.getenv("AVALON_TASK", None)
|
||||
# creating instances per write node
|
||||
file_path = context.data["currentFile"]
|
||||
staging_dir = os.path.dirname(file_path)
|
||||
base_name = os.path.basename(file_path)
|
||||
staging_dir = os.path.dirname(current_file)
|
||||
base_name = os.path.basename(current_file)
|
||||
subset = family + task.capitalize()
|
||||
|
||||
# Get frame range
|
||||
|
|
@ -62,6 +61,8 @@ class CollectWorkfile(pyblish.api.ContextPlugin):
|
|||
"handleEnd": handle_end,
|
||||
"step": 1,
|
||||
"fps": root['fps'].value(),
|
||||
|
||||
"currentFile": current_file
|
||||
}
|
||||
context.data.update(script_data)
|
||||
|
||||
|
|
@ -90,4 +91,9 @@ class CollectWorkfile(pyblish.api.ContextPlugin):
|
|||
instance.data["representations"].append(representation)
|
||||
|
||||
self.log.info('Publishing script version')
|
||||
|
||||
# create instances in context data if not are created yet
|
||||
if not context.data.get("instances"):
|
||||
context.data["instances"] = list()
|
||||
|
||||
context.data["instances"].append(instance)
|
||||
|
|
@ -1,14 +1,15 @@
|
|||
import os
|
||||
import nuke
|
||||
import pyblish.api
|
||||
import pype.api as pype
|
||||
|
||||
|
||||
@pyblish.api.log
|
||||
class CollectNukeWrites(pyblish.api.InstancePlugin):
|
||||
"""Collect all write nodes."""
|
||||
|
||||
order = pyblish.api.CollectorOrder + 0.1
|
||||
label = "Collect Writes"
|
||||
order = pyblish.api.CollectorOrder - 0.58
|
||||
label = "Pre-collect Writes"
|
||||
hosts = ["nuke", "nukeassist"]
|
||||
families = ["write"]
|
||||
|
||||
|
|
@ -39,11 +40,11 @@ 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
|
||||
)
|
||||
frame_length = int(last_frame - first_frame + 1)
|
||||
review = instance.data["review"]
|
||||
|
||||
if node["use_limit"].getValue():
|
||||
first_frame = int(node["first"].getValue())
|
||||
|
|
@ -58,7 +59,7 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
|
|||
if "prerender" in f),
|
||||
None) and self.sync_workfile_version:
|
||||
# get version to instance for integration
|
||||
instance.data['version'] = instance.context.data["version"]
|
||||
instance.data['version'] = pype.get_version_from_path(current_file)
|
||||
|
||||
self.log.debug('Write Version: %s' % instance.data('version'))
|
||||
|
||||
|
|
@ -79,7 +80,8 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
|
|||
representation = {
|
||||
'name': ext,
|
||||
'ext': ext,
|
||||
"stagingDir": output_dir
|
||||
"stagingDir": output_dir,
|
||||
"tags": list()
|
||||
}
|
||||
|
||||
try:
|
||||
|
|
@ -108,6 +110,10 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
|
|||
collected_frames.insert(0, slate_frame)
|
||||
|
||||
representation['files'] = collected_frames
|
||||
# add review if any
|
||||
if review:
|
||||
representation["tags"].extend(["review", "ftrackreview"])
|
||||
|
||||
instance.data["representations"].append(representation)
|
||||
except Exception:
|
||||
instance.data["representations"].append(representation)
|
||||
Loading…
Add table
Add a link
Reference in a new issue