Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Nuke: unified clip loader #2128

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions openpype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def install():
"""Install Pype to Avalon."""
from pyblish.lib import MessageHandler
from openpype.modules import load_modules
from avalon import pipeline

# Make sure modules are loaded
load_modules()
Expand Down Expand Up @@ -117,7 +118,9 @@ def modified_emit(obj, record):

# apply monkey patched discover to original one
log.info("Patching discovery")

avalon.discover = patched_discover
pipeline.discover = patched_discover

avalon.on("taskChanged", _on_task_change)

Expand Down
71 changes: 71 additions & 0 deletions openpype/hosts/nuke/api/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import random
import string

import avalon.nuke
from avalon.nuke import lib as anlib
from avalon import api

from openpype.api import (
get_current_project_settings,
PypeCreatorMixin
Expand All @@ -23,3 +29,68 @@ def __init__(self, *args, **kwargs):
self.log.error(msg + '\n\nPlease use other subset name!')
raise NameError("`{0}: {1}".format(__name__, msg))
return


def get_review_presets_config():
settings = get_current_project_settings()
review_profiles = (
settings["global"]
["publish"]
["ExtractReview"]
["profiles"]
)

outputs = {}
for profile in review_profiles:
outputs.update(profile.get("outputs", {}))

return [str(name) for name, _prop in outputs.items()]


class NukeLoader(api.Loader):
container_id_knob = "containerId"
container_id = ''.join(random.choice(
string.ascii_uppercase + string.digits) for _ in range(10))

def get_container_id(self, node):
id_knob = node.knobs().get(self.container_id_knob)
return id_knob.value() if id_knob else None

def get_members(self, source):
"""Return nodes that has same 'containerId' as `source`"""
source_id = self.get_container_id(source)
return [node for node in nuke.allNodes(recurseGroups=True)
if self.get_container_id(node) == source_id
and node is not source] if source_id else []

def set_as_member(self, node):
source_id = self.get_container_id(node)

if source_id:
node[self.container_id_knob].setValue(self.container_id)
else:
HIDEN_FLAG = 0x00040000
_knob = anlib.Knobby(
"String_Knob",
self.container_id,
flags=[nuke.READ_ONLY, HIDEN_FLAG])
knob = _knob.create(self.container_id_knob)
node.addKnob(knob)

def clear_members(self, parent_node):
members = self.get_members(parent_node)

dependent_nodes = None
for node in members:
_depndc = [n for n in node.dependent() if n not in members]
if not _depndc:
continue

dependent_nodes = _depndc
break

for member in members:
self.log.info("removing node: `{}".format(member.name()))
nuke.delete(member)

return dependent_nodes
37 changes: 37 additions & 0 deletions openpype/hosts/nuke/plugins/inventory/repair_old_loaders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from avalon import api, style
from avalon.nuke import lib as anlib
from openpype.api import (
Logger)


class RepairOldLoaders(api.InventoryAction):

label = "Repair Old Loaders"
icon = "gears"
color = style.colors.alert

log = Logger().get_logger(__name__)

def process(self, containers):
import nuke
new_loader = "LoadClip"

for cdata in containers:
orig_loader = cdata["loader"]
orig_name = cdata["objectName"]
if orig_loader not in ["LoadSequence", "LoadMov"]:
self.log.warning(
"This repair action is only working on "
"`LoadSequence` and `LoadMov` Loaders")
continue

new_name = orig_name.replace(orig_loader, new_loader)
node = nuke.toNode(cdata["objectName"])

cdata.update({
"loader": new_loader,
"objectName": new_name
})
node["name"].setValue(new_name)
# get data from avalon knob
anlib.set_avalon_knob_data(node, cdata)
4 changes: 2 additions & 2 deletions openpype/hosts/nuke/plugins/inventory/select_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class SelectContainers(api.InventoryAction):
color = "#d8d8d8"

def process(self, containers):

import nuke
import avalon.nuke

nodes = [i["_node"] for i in containers]
nodes = [nuke.toNode(i["objectName"]) for i in containers]

with avalon.nuke.viewer_update_and_undo_stop():
# clear previous_selection
Expand Down
68 changes: 0 additions & 68 deletions openpype/hosts/nuke/plugins/inventory/set_tool_color.py

This file was deleted.

Loading