mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
Repair legacy write nodes.
Grabs the existing data from the legacy write nodes, and creates a new write from it.
This commit is contained in:
parent
c139c7f3e2
commit
9073feb469
2 changed files with 87 additions and 0 deletions
25
pype/plugins/nuke/publish/collect_legacy_write.py
Normal file
25
pype/plugins/nuke/publish/collect_legacy_write.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import nuke
|
||||
|
||||
import pyblish.api
|
||||
|
||||
|
||||
class CollectWriteLegacy(pyblish.api.ContextPlugin):
|
||||
"""Collect legacy write nodes."""
|
||||
|
||||
order = pyblish.api.CollectorOrder
|
||||
label = "Collect Write Legacy"
|
||||
hosts = ["nuke", "nukeassist"]
|
||||
|
||||
def process(self, context):
|
||||
|
||||
for node in nuke.allNodes():
|
||||
if node.Class() != "Write":
|
||||
continue
|
||||
|
||||
if "avalon" not in node.knobs().keys():
|
||||
continue
|
||||
|
||||
instance = context.create_instance(
|
||||
node.name(), family="write.legacy"
|
||||
)
|
||||
instance.append(node)
|
||||
62
pype/plugins/nuke/publish/validate_write_legacy.py
Normal file
62
pype/plugins/nuke/publish/validate_write_legacy.py
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import toml
|
||||
import os
|
||||
|
||||
import nuke
|
||||
|
||||
from avalon import api
|
||||
import pyblish.api
|
||||
|
||||
|
||||
class RepairWriteLegacyAction(pyblish.api.Action):
|
||||
|
||||
label = "Repair"
|
||||
icon = "wrench"
|
||||
on = "failed"
|
||||
|
||||
def process(self, context, plugin):
|
||||
|
||||
# Get the errored instances
|
||||
failed = []
|
||||
for result in context.data["results"]:
|
||||
if (result["error"] is not None and result["instance"] is not None
|
||||
and result["instance"] not in failed):
|
||||
failed.append(result["instance"])
|
||||
|
||||
# Apply pyblish.logic to get the instances for the plug-in
|
||||
instances = pyblish.api.instances_by_plugin(failed, plugin)
|
||||
|
||||
for instance in instances:
|
||||
data = toml.loads(instance[0]["avalon"].value())
|
||||
data["xpos"] = instance[0].xpos()
|
||||
data["ypos"] = instance[0].ypos()
|
||||
data["input"] = instance[0].input(0)
|
||||
data["publish"] = instance[0]["publish"].value()
|
||||
data["render"] = instance[0]["render"].value()
|
||||
data["render_farm"] = instance[0]["render_farm"].value()
|
||||
|
||||
nuke.delete(instance[0])
|
||||
|
||||
family = "render{}".format(os.environ["AVALON_TASK"].capitalize())
|
||||
api.create(data["subset"], data["asset"], family)
|
||||
node = nuke.toNode(data["subset"])
|
||||
node.setXYpos(data["xpos"], data["ypos"])
|
||||
node.setInput(0, data["input"])
|
||||
node["publish"].setValue(data["publish"])
|
||||
node["render"].setValue(data["render"])
|
||||
node["render_farm"].setValue(data["render_farm"])
|
||||
|
||||
|
||||
class ValidateWriteLegacy(pyblish.api.InstancePlugin):
|
||||
"""Validate legacy write nodes."""
|
||||
|
||||
order = pyblish.api.ValidatorOrder
|
||||
optional = True
|
||||
families = ["write.legacy"]
|
||||
label = "Write Legacy"
|
||||
hosts = ["nuke"]
|
||||
actions = [RepairWriteLegacyAction]
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
msg = "Clean up legacy write node \"{}\"".format(instance)
|
||||
assert False, msg
|
||||
Loading…
Add table
Add a link
Reference in a new issue