From 066c38b4becf9351c597c4573b7d245a04c520a0 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 2 Oct 2020 15:51:35 +0200 Subject: [PATCH 1/4] fix(nuke): broken gizmo workflow --- pype/plugins/nuke/load/load_gizmo.py | 186 ++++++++++++++++++ pype/plugins/nuke/load/load_gizmo_ip.py | 1 - pype/plugins/nuke/publish/collect_gizmo.py | 2 +- .../plugins/nuke/publish/collect_instances.py | 6 +- 4 files changed, 188 insertions(+), 7 deletions(-) create mode 100644 pype/plugins/nuke/load/load_gizmo.py diff --git a/pype/plugins/nuke/load/load_gizmo.py b/pype/plugins/nuke/load/load_gizmo.py new file mode 100644 index 0000000000..58b7db667e --- /dev/null +++ b/pype/plugins/nuke/load/load_gizmo.py @@ -0,0 +1,186 @@ +from avalon import api, style, io +import nuke +from avalon.nuke import lib as anlib +from avalon.nuke import containerise, update_container + + +class LoadGizmo(api.Loader): + """Loading nuke Gizmo""" + + representations = ["gizmo"] + families = ["gizmo"] + + label = "Load Gizmo" + order = 0 + icon = "dropbox" + color = style.colors.light + node_color = "0x75338eff" + + def load(self, context, name, namespace, data): + """ + Loading function to get Gizmo into node graph + + Arguments: + context (dict): context of version + name (str): name of the version + namespace (str): asset name + data (dict): compulsory attribute > not used + + Returns: + nuke node: containerised nuke node object + """ + + # get main variables + version = context['version'] + version_data = version.get("data", {}) + vname = version.get("name", None) + first = version_data.get("frameStart", None) + last = version_data.get("frameEnd", None) + namespace = namespace or context['asset']['name'] + colorspace = version_data.get("colorspace", None) + object_name = "{}_{}".format(name, namespace) + + # prepare data for imprinting + # add additional metadata from the version to imprint to Avalon knob + add_keys = ["frameStart", "frameEnd", "handleStart", "handleEnd", + "source", "author", "fps"] + + data_imprint = {"frameStart": first, + "frameEnd": last, + "version": vname, + "colorspaceInput": colorspace, + "objectName": object_name} + + for k in add_keys: + data_imprint.update({k: version_data[k]}) + + # getting file path + file = self.fname.replace("\\", "/") + + # adding nodes to node graph + # just in case we are in group lets jump out of it + nuke.endGroup() + + with anlib.maintained_selection(): + # add group from nk + nuke.nodePaste(file) + + GN = nuke.selectedNode() + + GN["name"].setValue(object_name) + + return containerise( + node=GN, + name=name, + namespace=namespace, + context=context, + loader=self.__class__.__name__, + data=data_imprint) + + def update(self, container, representation): + """Update the Loader's path + + Nuke automatically tries to reset some variables when changing + the loader's path to a new file. These automatic changes are to its + inputs: + + """ + + # get main variables + # Get version from io + version = io.find_one({ + "type": "version", + "_id": representation["parent"] + }) + # get corresponding node + GN = nuke.toNode(container['objectName']) + + file = api.get_representation_path(representation).replace("\\", "/") + name = container['name'] + version_data = version.get("data", {}) + vname = version.get("name", None) + first = version_data.get("frameStart", None) + last = version_data.get("frameEnd", None) + namespace = container['namespace'] + colorspace = version_data.get("colorspace", None) + object_name = "{}_{}".format(name, namespace) + + add_keys = ["frameStart", "frameEnd", "handleStart", "handleEnd", + "source", "author", "fps"] + + data_imprint = {"representation": str(representation["_id"]), + "frameStart": first, + "frameEnd": last, + "version": vname, + "colorspaceInput": colorspace, + "objectName": object_name} + + for k in add_keys: + data_imprint.update({k: version_data[k]}) + + # adding nodes to node graph + # just in case we are in group lets jump out of it + nuke.endGroup() + + with anlib.maintained_selection(): + xpos = GN.xpos() + ypos = GN.ypos() + avalon_data = anlib.get_avalon_knob_data(GN) + nuke.delete(GN) + # add group from nk + nuke.nodePaste(file) + + GN = nuke.selectedNode() + anlib.set_avalon_knob_data(GN, avalon_data) + GN.setXYpos(xpos, ypos) + GN["name"].setValue(object_name) + + # get all versions in list + versions = io.find({ + "type": "version", + "parent": version["parent"] + }).distinct('name') + + max_version = max(versions) + + # change color of node + if version.get("name") not in [max_version]: + GN["tile_color"].setValue(int("0xd88467ff", 16)) + else: + GN["tile_color"].setValue(int(self.node_color, 16)) + + self.log.info("udated to version: {}".format(version.get("name"))) + + return update_container(GN, data_imprint) + + def byteify(self, input): + """ + Converts unicode strings to strings + It goes trought all dictionary + + Arguments: + input (dict/str): input + + Returns: + dict: with fixed values and keys + + """ + + if isinstance(input, dict): + return {self.byteify(key): self.byteify(value) + for key, value in input.iteritems()} + elif isinstance(input, list): + return [self.byteify(element) for element in input] + elif isinstance(input, unicode): + return input.encode('utf-8') + else: + return input + + def switch(self, container, representation): + self.update(container, representation) + + def remove(self, container): + from avalon.nuke import viewer_update_and_undo_stop + node = nuke.toNode(container['objectName']) + with viewer_update_and_undo_stop(): + nuke.delete(node) diff --git a/pype/plugins/nuke/load/load_gizmo_ip.py b/pype/plugins/nuke/load/load_gizmo_ip.py index e735e27bbf..a2e8a6abb8 100644 --- a/pype/plugins/nuke/load/load_gizmo_ip.py +++ b/pype/plugins/nuke/load/load_gizmo_ip.py @@ -102,7 +102,6 @@ class LoadGizmoInputProcess(api.Loader): GN = nuke.toNode(container['objectName']) file = api.get_representation_path(representation).replace("\\", "/") - context = representation["context"] name = container['name'] version_data = version.get("data", {}) vname = version.get("name", None) diff --git a/pype/plugins/nuke/publish/collect_gizmo.py b/pype/plugins/nuke/publish/collect_gizmo.py index 11e8c17a3f..6436bdc562 100644 --- a/pype/plugins/nuke/publish/collect_gizmo.py +++ b/pype/plugins/nuke/publish/collect_gizmo.py @@ -31,7 +31,7 @@ class CollectGizmo(pyblish.api.InstancePlugin): # get version version = pype.get_version_from_path(nuke.root().name()) - instance.data['version'] = version + instance.data['version'] = int(version) # Add version data to instance version_data = { diff --git a/pype/plugins/nuke/publish/collect_instances.py b/pype/plugins/nuke/publish/collect_instances.py index 9085e12bd8..26a5bf3a2a 100644 --- a/pype/plugins/nuke/publish/collect_instances.py +++ b/pype/plugins/nuke/publish/collect_instances.py @@ -37,7 +37,6 @@ class CollectNukeInstances(pyblish.api.ContextPlugin): except Exception as E: self.log.warning(E) - # get data from avalon knob self.log.debug("node[name]: {}".format(node['name'].value())) avalon_knob_data = get_avalon_knob_data(node, ["avalon:", "ak:"]) @@ -60,7 +59,6 @@ class CollectNukeInstances(pyblish.api.ContextPlugin): families.append(family) - # except disabled nodes but exclude backdrops in test if ("nukenodes" not in family) and (node["disable"].value()): continue @@ -75,8 +73,7 @@ class CollectNukeInstances(pyblish.api.ContextPlugin): # Add all nodes in group instances. if node.Class() == "Group": # only alter families for render family - if "write" in families_ak: - + if "write" == families_ak: if node["render"].value(): self.log.info("flagged for render") add_family = "{}.local".format("render") @@ -97,7 +94,6 @@ class CollectNukeInstances(pyblish.api.ContextPlugin): self.log.debug("__ families: `{}`".format(families)) - # Get format format = root['format'].value() resolution_width = format.width() From 8fff3f2fbacba1fcc1b44cfdc211ff326ef2fcf0 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 2 Oct 2020 15:55:05 +0200 Subject: [PATCH 2/4] clean(nuke): hound fixes --- pype/plugins/nuke/load/load_gizmo.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/pype/plugins/nuke/load/load_gizmo.py b/pype/plugins/nuke/load/load_gizmo.py index 58b7db667e..c6228b95f6 100644 --- a/pype/plugins/nuke/load/load_gizmo.py +++ b/pype/plugins/nuke/load/load_gizmo.py @@ -153,29 +153,6 @@ class LoadGizmo(api.Loader): return update_container(GN, data_imprint) - def byteify(self, input): - """ - Converts unicode strings to strings - It goes trought all dictionary - - Arguments: - input (dict/str): input - - Returns: - dict: with fixed values and keys - - """ - - if isinstance(input, dict): - return {self.byteify(key): self.byteify(value) - for key, value in input.iteritems()} - elif isinstance(input, list): - return [self.byteify(element) for element in input] - elif isinstance(input, unicode): - return input.encode('utf-8') - else: - return input - def switch(self, container, representation): self.update(container, representation) From d4611c6dadab16a554c9d7ce075ee12176a890ef Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Mon, 5 Oct 2020 11:30:05 +0200 Subject: [PATCH 3/4] bump version --- pype/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/version.py b/pype/version.py index 0f90260218..521faacafe 100644 --- a/pype/version.py +++ b/pype/version.py @@ -1 +1 @@ -__version__ = "2.12.2" +__version__ = "2.12.3" From 596520dec85373f0e9b944e3b52c060ea522aae8 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Mon, 5 Oct 2020 12:46:10 +0200 Subject: [PATCH 4/4] allow skipping of resolution check for a task name --- pype/hosts/harmony/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pype/hosts/harmony/__init__.py b/pype/hosts/harmony/__init__.py index f920e38765..a6a3310374 100644 --- a/pype/hosts/harmony/__init__.py +++ b/pype/hosts/harmony/__init__.py @@ -7,6 +7,7 @@ from avalon.vendor import Qt import avalon.tools.sceneinventory import pyblish.api from pype import lib +from pype.api import config signature = str(uuid4()) @@ -53,7 +54,7 @@ def get_asset_settings(): resolution_width = asset_data.get("resolutionWidth") resolution_height = asset_data.get("resolutionHeight") - return { + scene_data = { "fps": fps, "frameStart": frame_start, "frameEnd": frame_end, @@ -61,6 +62,15 @@ def get_asset_settings(): "resolutionHeight": resolution_height } + harmony_config = config.get_presets().["harmony"]["general"] + + skip_resolution_check = harmony_config.get(["skip_resolution_check"], []) + if os.getenv('AVALON_TASK') in skip_resolution_check: + scene_data.pop("resolutionWidth") + scene_data.pop("resolutionHeight") + + return scene_data + def ensure_scene_settings(): settings = get_asset_settings()