mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-27 14:22:37 +01:00
create read works. Basic collector
This commit is contained in:
parent
8db9d6725b
commit
2548cfb0d6
2 changed files with 128 additions and 114 deletions
|
|
@ -10,30 +10,20 @@ import nuke
|
|||
log = pype.Logger.getLogger(__name__, "nuke")
|
||||
|
||||
|
||||
def subset_to_families(subset, family, families):
|
||||
subset_sufx = str(subset).replace(family, "")
|
||||
new_subset = families + subset_sufx
|
||||
return "{}.{}".format(family, new_subset)
|
||||
|
||||
|
||||
class CrateRead(avalon.nuke.Creator):
|
||||
# change this to template preset
|
||||
preset = "render"
|
||||
|
||||
name = "WriteRender"
|
||||
label = "Create Write Render"
|
||||
name = "ReadCopy"
|
||||
label = "Create Read Copy"
|
||||
hosts = ["nuke"]
|
||||
family = "{}_write".format(preset)
|
||||
families = preset
|
||||
# family = "read"
|
||||
family = "source"
|
||||
icon = "sign-out"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CrateWriteRender, self).__init__(*args, **kwargs)
|
||||
super(CrateRead, self).__init__(*args, **kwargs)
|
||||
|
||||
data = OrderedDict()
|
||||
|
||||
data["family"] = self.family.split("_")[1]
|
||||
data["families"] = self.families
|
||||
data['family'] = self.family
|
||||
|
||||
{data.update({k: v}) for k, v in self.data.items()
|
||||
if k not in data.keys()}
|
||||
|
|
@ -42,106 +32,25 @@ class CrateRead(avalon.nuke.Creator):
|
|||
def process(self):
|
||||
self.name = self.data["subset"]
|
||||
|
||||
family = self.family.split("_")[0]
|
||||
node = self.family.split("_")[1]
|
||||
nodes = nuke.selectedNodes()
|
||||
|
||||
instance = nuke.toNode(self.data["subset"])
|
||||
|
||||
if not instance:
|
||||
write_data = {
|
||||
"class": node,
|
||||
"preset": family,
|
||||
"avalon": self.data
|
||||
}
|
||||
|
||||
create_write_node(self.data["subset"], write_data)
|
||||
if not nodes:
|
||||
nuke.message('Please select Read node')
|
||||
elif len(nodes) == 1:
|
||||
if nodes[0].Class() != 'Read':
|
||||
nuke.message('Please select Read node')
|
||||
else:
|
||||
|
||||
node = nodes[0]
|
||||
name = node["name"].value()
|
||||
avalon_data = self.data
|
||||
avalon_data['subset'] = "{}_{}".format(self.family, name)
|
||||
change_read_node(self.data["subset"], node, avalon_data)
|
||||
else:
|
||||
nuke.message('Please select only one Read node')
|
||||
return
|
||||
|
||||
|
||||
class CrateWritePrerender(avalon.nuke.Creator):
|
||||
# change this to template preset
|
||||
preset = "prerender"
|
||||
|
||||
name = "WritePrerender"
|
||||
label = "Create Write Prerender"
|
||||
hosts = ["nuke"]
|
||||
family = "{}_write".format(preset)
|
||||
families = preset
|
||||
icon = "sign-out"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CrateWritePrerender, self).__init__(*args, **kwargs)
|
||||
|
||||
data = OrderedDict()
|
||||
|
||||
data["family"] = self.family.split("_")[1]
|
||||
data["families"] = self.families
|
||||
|
||||
{data.update({k: v}) for k, v in self.data.items()
|
||||
if k not in data.keys()}
|
||||
self.data = data
|
||||
|
||||
def process(self):
|
||||
self.name = self.data["subset"]
|
||||
|
||||
instance = nuke.toNode(self.data["subset"])
|
||||
|
||||
family = self.family.split("_")[0]
|
||||
node = self.family.split("_")[1]
|
||||
|
||||
if not instance:
|
||||
write_data = {
|
||||
"class": node,
|
||||
"preset": family,
|
||||
"avalon": self.data
|
||||
}
|
||||
|
||||
create_write_node(self.data["subset"], write_data)
|
||||
|
||||
return
|
||||
|
||||
|
||||
class CrateWriteStill(avalon.nuke.Creator):
|
||||
# change this to template preset
|
||||
preset = "still"
|
||||
|
||||
name = "WriteStill"
|
||||
label = "Create Write Still"
|
||||
hosts = ["nuke"]
|
||||
family = "{}_write".format(preset)
|
||||
families = preset
|
||||
icon = "image"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CrateWriteStill, self).__init__(*args, **kwargs)
|
||||
|
||||
data = OrderedDict()
|
||||
|
||||
data["family"] = self.family.split("_")[1]
|
||||
data["families"] = self.families
|
||||
|
||||
{data.update({k: v}) for k, v in self.data.items()
|
||||
if k not in data.keys()}
|
||||
self.data = data
|
||||
|
||||
def process(self):
|
||||
self.name = self.data["subset"]
|
||||
|
||||
instance = nuke.toNode(self.data["subset"])
|
||||
|
||||
family = self.family.split("_")[0]
|
||||
node = self.family.split("_")[1]
|
||||
|
||||
if not instance:
|
||||
write_data = {
|
||||
"frame_range": [nuke.frame(), nuke.frame()],
|
||||
"class": node,
|
||||
"preset": family,
|
||||
"avalon": self.data
|
||||
}
|
||||
|
||||
nuke.createNode("FrameHold", "first_frame {}".format(nuke.frame()))
|
||||
create_write_node(self.data["subset"], write_data)
|
||||
|
||||
return
|
||||
def change_read_node(name, node, data):
|
||||
node = avalon.nuke.lib.imprint(node, data)
|
||||
node['tile_color'].setValue(16711935)
|
||||
|
|
|
|||
105
pype/plugins/nuke/publish/collect_reades.py
Normal file
105
pype/plugins/nuke/publish/collect_reades.py
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
import os
|
||||
import re
|
||||
|
||||
import nuke
|
||||
import pyblish.api
|
||||
import logging
|
||||
from avalon import io, api
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pyblish.api.log
|
||||
class CollectNukeWrites(pyblish.api.ContextPlugin):
|
||||
"""Collect all write nodes."""
|
||||
|
||||
order = pyblish.api.CollectorOrder + 0.1
|
||||
label = "Collect Writes"
|
||||
hosts = ["nuke", "nukeassist"]
|
||||
|
||||
def process(self, context):
|
||||
asset_data = io.find_one({"type": "asset",
|
||||
"name": api.Session["AVALON_ASSET"]})
|
||||
self.log.debug("asset_data: {}".format(asset_data["data"]))
|
||||
for instance in context.data["instances"]:
|
||||
self.log.debug("checking instance: {}".format(instance))
|
||||
|
||||
node = instance[0]
|
||||
if node.Class() != "Read":
|
||||
continue
|
||||
|
||||
file_path = node["file"].value()
|
||||
items = file_path.split(".")
|
||||
|
||||
isSequence = False
|
||||
if len(items) > 1:
|
||||
sequence = items[-2]
|
||||
print sequence
|
||||
hash_regex = re.compile(r"([#*])")
|
||||
seq_regex = re.compile('[%0-9*d]')
|
||||
hash_match = re.match(hash_regex, sequence)
|
||||
seq_match = re.match(seq_regex, sequence)
|
||||
if hash_match is True or seq_match is True:
|
||||
isSequence = True
|
||||
|
||||
# Get frame range
|
||||
first_frame = int(nuke.root()["first_frame"].getValue())
|
||||
last_frame = int(nuke.root()["last_frame"].getValue())
|
||||
|
||||
if node["use_limit"].getValue():
|
||||
first_frame = int(node["first"].getValue())
|
||||
last_frame = int(node["last"].getValue())
|
||||
|
||||
# get source path
|
||||
source_path = nuke.filename(node)
|
||||
source_dir = os.path.dirname(source_path)
|
||||
self.log.debug('source dir: {}'.format(source_dir))
|
||||
# Include start and end render frame in label
|
||||
name = node.name()
|
||||
|
||||
label = "{0} ({1}-{2})".format(
|
||||
name,
|
||||
int(first_frame),
|
||||
int(last_frame)
|
||||
)
|
||||
|
||||
# preredered frames
|
||||
if not node["render"].value():
|
||||
families = "prerendered.frames"
|
||||
collected_frames = os.listdir(output_dir)
|
||||
self.log.debug("collected_frames: {}".format(label))
|
||||
if "files" not in instance.data:
|
||||
instance.data["files"] = list()
|
||||
instance.data["files"].append(collected_frames)
|
||||
instance.data['transfer'] = False
|
||||
else:
|
||||
# dealing with local/farm rendering
|
||||
if node["render_farm"].value():
|
||||
families = "{}.farm".format(instance.data["avalonKnob"]["families"][0])
|
||||
else:
|
||||
families = "{}.local".format(instance.data["avalonKnob"]["families"][0])
|
||||
|
||||
self.log.debug("checking for error: {}".format(label))
|
||||
instance.data.update({
|
||||
"path": path,
|
||||
"outputDir": output_dir,
|
||||
"ext": ext,
|
||||
"label": label,
|
||||
"families": [families, 'ftrack'],
|
||||
"startFrame": first_frame,
|
||||
"endFrame": last_frame,
|
||||
"outputType": output_type,
|
||||
"stagingDir": output_dir,
|
||||
"colorspace": node["colorspace"].value(),
|
||||
"handles": int(asset_data["data"].get("handles", 0)),
|
||||
"step": 1,
|
||||
"fps": int(nuke.root()['fps'].value())
|
||||
})
|
||||
|
||||
self.log.debug("instance.data: {}".format(instance.data))
|
||||
|
||||
self.log.debug("context: {}".format(context))
|
||||
|
||||
def sort_by_family(self, instance):
|
||||
"""Sort by family"""
|
||||
return instance.data.get("families", instance.data.get("family"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue