From 2589ce46711fbf19d4c3c9a56fe8c10cad01ef01 Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Mon, 27 Sep 2021 14:09:02 +0200 Subject: [PATCH] hda updating --- .../hosts/houdini/plugins/create/create_hda.py | 3 +++ openpype/hosts/houdini/plugins/load/load_hda.py | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/houdini/plugins/create/create_hda.py b/openpype/hosts/houdini/plugins/create/create_hda.py index d58e0c5e52..05307d4c56 100644 --- a/openpype/hosts/houdini/plugins/create/create_hda.py +++ b/openpype/hosts/houdini/plugins/create/create_hda.py @@ -41,6 +41,9 @@ class CreateHDA(plugin.Creator): hda_node.setName(self.name) hou.moveNodesTo(self.nodes, hda_node) hda_node.layoutChildren() + # delete node created by Avalon in /out + # this needs to be addressed in future Houdini workflow refactor. + hou.node("/out/{}".format(self.name)).destroy() lib.imprint(hda_node, self.data) diff --git a/openpype/hosts/houdini/plugins/load/load_hda.py b/openpype/hosts/houdini/plugins/load/load_hda.py index 5e04d83e86..f923b699d2 100644 --- a/openpype/hosts/houdini/plugins/load/load_hda.py +++ b/openpype/hosts/houdini/plugins/load/load_hda.py @@ -15,7 +15,6 @@ class HdaLoader(api.Loader): color = "orange" def load(self, context, name=None, namespace=None, data=None): - import os import hou @@ -33,7 +32,6 @@ class HdaLoader(api.Loader): node_name = "{0}_{1:03d}".format(formatted, counter) hou.hda.installFile(file_path) - print("installing {}".format(name)) hda_node = obj.createNode(name, node_name) self[:] = [hda_node] @@ -48,9 +46,17 @@ class HdaLoader(api.Loader): ) def update(self, container, representation): - hda_node = container["node"] - hda_def = hda_node.type().definition() + import hou + hda_node = container["node"] + file_path = api.get_representation_path(representation) + file_path = file_path.replace("\\", "/") + hou.hda.installFile(file_path) + defs = hda_node.type().allInstalledDefinitions() + def_paths = [d.libraryFilePath() for d in defs] + new = def_paths.index(file_path) + defs[new].setIsPreferred(True) def remove(self, container): - pass + node = container["node"] + node.destroy()