From 1910b5ec958b8259ea0bf372b65de8ea6059addc Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 19 May 2021 17:24:27 +0200 Subject: [PATCH] Nuke: updating loaders for effects --- .../load/{load_luts.py => load_effects.py} | 32 ++++++++++++------- .../{load_luts_ip.py => load_effects_ip.py} | 25 ++++++++------- 2 files changed, 34 insertions(+), 23 deletions(-) rename openpype/hosts/nuke/plugins/load/{load_luts.py => load_effects.py} (94%) rename openpype/hosts/nuke/plugins/load/{load_luts_ip.py => load_effects_ip.py} (95%) diff --git a/openpype/hosts/nuke/plugins/load/load_luts.py b/openpype/hosts/nuke/plugins/load/load_effects.py similarity index 94% rename from openpype/hosts/nuke/plugins/load/load_luts.py rename to openpype/hosts/nuke/plugins/load/load_effects.py index 85ec3e2060..6306767f37 100644 --- a/openpype/hosts/nuke/plugins/load/load_luts.py +++ b/openpype/hosts/nuke/plugins/load/load_effects.py @@ -4,18 +4,19 @@ import json from collections import OrderedDict -class LoadLuts(api.Loader): +class LoadEffects(api.Loader): """Loading colorspace soft effect exported from nukestudio""" - representations = ["lutJson"] - families = ["lut"] + representations = ["effectJson"] + families = ["effect"] - label = "Load Luts - nodes" + label = "Load Effects - nodes" order = 0 icon = "cc" color = style.colors.light ignore_attr = ["useLifetime"] + def load(self, context, name, namespace, data): """ Loading function to get the soft effects to particular read node @@ -66,15 +67,15 @@ class LoadLuts(api.Loader): for key, value in json.load(f).iteritems()} # get correct order of nodes by positions on track and subtrack - nodes_order = self.reorder_nodes(json_f["effects"]) + nodes_order = self.reorder_nodes(json_f) # adding nodes to node graph # just in case we are in group lets jump out of it nuke.endGroup() - GN = nuke.createNode("Group") - - GN["name"].setValue(object_name) + GN = nuke.createNode( + "Group", + "name {}_1".format(object_name)) # adding content to the group node with GN: @@ -186,7 +187,7 @@ class LoadLuts(api.Loader): for key, value in json.load(f).iteritems()} # get correct order of nodes by positions on track and subtrack - nodes_order = self.reorder_nodes(json_f["effects"]) + nodes_order = self.reorder_nodes(json_f) # adding nodes to node graph # just in case we are in group lets jump out of it @@ -266,7 +267,11 @@ class LoadLuts(api.Loader): None: if nothing found """ search_name = "{0}_{1}".format(asset, subset) - node = [n for n in nuke.allNodes() if search_name in n["name"].value()] + + node = [ + n for n in nuke.allNodes(filter="Read") + if search_name in n["file"].value() + ] if len(node) > 0: rn = node[0] else: @@ -286,8 +291,10 @@ class LoadLuts(api.Loader): def reorder_nodes(self, data): new_order = OrderedDict() - trackNums = [v["trackIndex"] for k, v in data.items()] - subTrackNums = [v["subTrackIndex"] for k, v in data.items()] + trackNums = [v["trackIndex"] for k, v in data.items() + if isinstance(v, dict)] + subTrackNums = [v["subTrackIndex"] for k, v in data.items() + if isinstance(v, dict)] for trackIndex in range( min(trackNums), max(trackNums) + 1): @@ -300,6 +307,7 @@ class LoadLuts(api.Loader): def get_item(self, data, trackIndex, subTrackIndex): return {key: val for key, val in data.items() + if isinstance(val, dict) if subTrackIndex == val["subTrackIndex"] if trackIndex == val["trackIndex"]} diff --git a/openpype/hosts/nuke/plugins/load/load_luts_ip.py b/openpype/hosts/nuke/plugins/load/load_effects_ip.py similarity index 95% rename from openpype/hosts/nuke/plugins/load/load_luts_ip.py rename to openpype/hosts/nuke/plugins/load/load_effects_ip.py index a0af29c7f4..6c71f2ae16 100644 --- a/openpype/hosts/nuke/plugins/load/load_luts_ip.py +++ b/openpype/hosts/nuke/plugins/load/load_effects_ip.py @@ -5,13 +5,13 @@ from collections import OrderedDict from openpype.hosts.nuke.api import lib -class LoadLutsInputProcess(api.Loader): +class LoadEffectsInputProcess(api.Loader): """Loading colorspace soft effect exported from nukestudio""" - representations = ["lutJson"] - families = ["lut"] + representations = ["effectJson"] + families = ["effect"] - label = "Load Luts - Input Process" + label = "Load Effects - Input Process" order = 0 icon = "eye" color = style.colors.alert @@ -67,15 +67,15 @@ class LoadLutsInputProcess(api.Loader): for key, value in json.load(f).iteritems()} # get correct order of nodes by positions on track and subtrack - nodes_order = self.reorder_nodes(json_f["effects"]) + nodes_order = self.reorder_nodes(json_f) # adding nodes to node graph # just in case we are in group lets jump out of it nuke.endGroup() - GN = nuke.createNode("Group") - - GN["name"].setValue(object_name) + GN = nuke.createNode( + "Group", + "name {}_1".format(object_name)) # adding content to the group node with GN: @@ -190,7 +190,7 @@ class LoadLutsInputProcess(api.Loader): for key, value in json.load(f).iteritems()} # get correct order of nodes by positions on track and subtrack - nodes_order = self.reorder_nodes(json_f["effects"]) + nodes_order = self.reorder_nodes(json_f) # adding nodes to node graph # just in case we are in group lets jump out of it @@ -304,8 +304,10 @@ class LoadLutsInputProcess(api.Loader): def reorder_nodes(self, data): new_order = OrderedDict() - trackNums = [v["trackIndex"] for k, v in data.items()] - subTrackNums = [v["subTrackIndex"] for k, v in data.items()] + trackNums = [v["trackIndex"] for k, v in data.items() + if isinstance(v, dict)] + subTrackNums = [v["subTrackIndex"] for k, v in data.items() + if isinstance(v, dict)] for trackIndex in range( min(trackNums), max(trackNums) + 1): @@ -318,6 +320,7 @@ class LoadLutsInputProcess(api.Loader): def get_item(self, data, trackIndex, subTrackIndex): return {key: val for key, val in data.items() + if isinstance(val, dict) if subTrackIndex == val["subTrackIndex"] if trackIndex == val["trackIndex"]}