From 182660d551d6c946ff282c225599b5f01e933b90 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 27 Jan 2022 19:04:34 +0100 Subject: [PATCH] OP-2414 - move from avalon to openpype --- openpype/hosts/harmony/api/TB_sceneOpened.js | 16 +-- openpype/hosts/harmony/api/__init__.py | 4 +- openpype/hosts/harmony/api/pipeline.py | 130 +++++++++---------- openpype/hosts/harmony/api/plugin.py | 4 +- openpype/hosts/harmony/api/toonboom/lib.py | 4 +- 5 files changed, 78 insertions(+), 80 deletions(-) diff --git a/openpype/hosts/harmony/api/TB_sceneOpened.js b/openpype/hosts/harmony/api/TB_sceneOpened.js index 6b1557e973..028a12b654 100644 --- a/openpype/hosts/harmony/api/TB_sceneOpened.js +++ b/openpype/hosts/harmony/api/TB_sceneOpened.js @@ -373,7 +373,7 @@ function start() { */ self.onCreator = function() { app.avalonClient.send({ - 'module': 'avalon.harmony.lib', + 'module': 'openpype.hosts.harmony.api.lib', 'method': 'show', 'args': ['creator'] }, false); @@ -388,7 +388,7 @@ function start() { */ self.onWorkfiles = function() { app.avalonClient.send({ - 'module': 'avalon.harmony.lib', + 'module': 'openpype.hosts.harmony.api.lib', 'method': 'show', 'args': ['workfiles'] }, false); @@ -403,7 +403,7 @@ function start() { */ self.onLoad = function() { app.avalonClient.send({ - 'module': 'avalon.harmony.lib', + 'module': 'openpype.hosts.harmony.api.lib', 'method': 'show', 'args': ['loader'] }, false); @@ -419,7 +419,7 @@ function start() { */ self.onPublish = function() { app.avalonClient.send({ - 'module': 'avalon.harmony.lib', + 'module': 'openpype.hosts.harmony.api.lib', 'method': 'show', 'args': ['publish'] }, false); @@ -435,7 +435,7 @@ function start() { */ self.onManage = function() { app.avalonClient.send({ - 'module': 'avalon.harmony.lib', + 'module': 'openpype.hosts.harmony.api.lib', 'method': 'show', 'args': ['sceneinventory'] }, false); @@ -451,7 +451,7 @@ function start() { */ self.onSubsetManage = function() { app.avalonClient.send({ - 'module': 'avalon.harmony.lib', + 'module': 'openpype.hosts.harmony.api.lib', 'method': 'show', 'args': ['subsetmanager'] }, false); @@ -467,7 +467,7 @@ function start() { */ self.onExperimentalTools = function() { app.avalonClient.send({ - 'module': 'avalon.harmony.lib', + 'module': 'openpype.hosts.harmony.api.lib', 'method': 'show', 'args': ['experimental_tools'] }, false); @@ -517,7 +517,7 @@ function ensureSceneSettings() { var app = QCoreApplication.instance(); app.avalonClient.send( { - "module": "pype.hosts.harmony.api", + "module": "openpype.hosts.harmony.api", "method": "ensure_scene_settings", "args": [] }, diff --git a/openpype/hosts/harmony/api/__init__.py b/openpype/hosts/harmony/api/__init__.py index c9f8ef0d08..286b8e3381 100644 --- a/openpype/hosts/harmony/api/__init__.py +++ b/openpype/hosts/harmony/api/__init__.py @@ -7,7 +7,7 @@ Anything that isn't defined here is INTERNAL and unreliable for external use. from .pipeline import ( ls, install, - # Creator, + Creator, list_instances, remove_instance, select_instance, @@ -52,7 +52,7 @@ __all__ = [ # pipeline "ls", "install", - #"Creator", + "Creator", "list_instances", "remove_instance", "select_instance", diff --git a/openpype/hosts/harmony/api/pipeline.py b/openpype/hosts/harmony/api/pipeline.py index 6d688f4711..d552d45939 100644 --- a/openpype/hosts/harmony/api/pipeline.py +++ b/openpype/hosts/harmony/api/pipeline.py @@ -318,71 +318,71 @@ def select_instance(instance): harmony.select_nodes([instance.get("uuid")]) -# class Creator(api.Creator): -# """Creator plugin to create instances in Harmony. -# -# By default a Composite node is created to support any number of nodes in -# an instance, but any node type is supported. -# If the selection is used, the selected nodes will be connected to the -# created node. -# """ -# -# node_type = "COMPOSITE" -# -# def setup_node(self, node): -# """Prepare node as container. -# -# Args: -# node (str): Path to node. -# """ -# harmony.send( -# { -# "function": "AvalonHarmony.setupNodeForCreator", -# "args": node -# } -# ) -# -# def process(self): -# """Plugin entry point.""" -# existing_node_names = harmony.send( -# { -# "function": "AvalonHarmony.getNodesNamesByType", -# "args": self.node_type -# })["result"] -# -# # Dont allow instances with the same name. -# msg = "Instance with name \"{}\" already exists.".format(self.name) -# for name in existing_node_names: -# if self.name.lower() == name.lower(): -# harmony.send( -# { -# "function": "AvalonHarmony.message", "args": msg -# } -# ) -# return False -# -# with harmony.maintained_selection() as selection: -# node = None -# -# if (self.options or {}).get("useSelection") and selection: -# node = harmony.send( -# { -# "function": "AvalonHarmony.createContainer", -# "args": [self.name, self.node_type, selection[-1]] -# } -# )["result"] -# else: -# node = harmony.send( -# { -# "function": "AvalonHarmony.createContainer", -# "args": [self.name, self.node_type] -# } -# )["result"] -# -# harmony.imprint(node, self.data) -# self.setup_node(node) -# -# return node +class Creator(avalon.api.Creator): + """Creator plugin to create instances in Harmony. + + By default a Composite node is created to support any number of nodes in + an instance, but any node type is supported. + If the selection is used, the selected nodes will be connected to the + created node. + """ + + node_type = "COMPOSITE" + + def setup_node(self, node): + """Prepare node as container. + + Args: + node (str): Path to node. + """ + harmony.send( + { + "function": "AvalonHarmony.setupNodeForCreator", + "args": node + } + ) + + def process(self): + """Plugin entry point.""" + existing_node_names = harmony.send( + { + "function": "AvalonHarmony.getNodesNamesByType", + "args": self.node_type + })["result"] + + # Dont allow instances with the same name. + msg = "Instance with name \"{}\" already exists.".format(self.name) + for name in existing_node_names: + if self.name.lower() == name.lower(): + harmony.send( + { + "function": "AvalonHarmony.message", "args": msg + } + ) + return False + + with harmony.maintained_selection() as selection: + node = None + + if (self.options or {}).get("useSelection") and selection: + node = harmony.send( + { + "function": "AvalonHarmony.createContainer", + "args": [self.name, self.node_type, selection[-1]] + } + )["result"] + else: + node = harmony.send( + { + "function": "AvalonHarmony.createContainer", + "args": [self.name, self.node_type] + } + )["result"] + + harmony.imprint(node, self.data) + self.setup_node(node) + + return node def containerise(name, diff --git a/openpype/hosts/harmony/api/plugin.py b/openpype/hosts/harmony/api/plugin.py index 7ac7fe510c..13a5625e72 100644 --- a/openpype/hosts/harmony/api/plugin.py +++ b/openpype/hosts/harmony/api/plugin.py @@ -1,6 +1,6 @@ -from avalon import harmony +from openpype.hosts.harmony.api import Creator from openpype.api import PypeCreatorMixin -class Creator(PypeCreatorMixin, harmony.Creator): +class Creator(PypeCreatorMixin, Creator): pass diff --git a/openpype/hosts/harmony/api/toonboom/lib.py b/openpype/hosts/harmony/api/toonboom/lib.py index f495aaf34c..e590c61f3c 100644 --- a/openpype/hosts/harmony/api/toonboom/lib.py +++ b/openpype/hosts/harmony/api/toonboom/lib.py @@ -56,9 +56,7 @@ def setup_startup_scripts(): * Use TB_sceneOpenedUI.js instead to manage startup logic * Add their startup logic to avalon/harmony/TB_sceneOpened.js """ - avalon_dcc_dir = os.path.join( - os.path.dirname(os.path.dirname(__file__)), "harmony" - ) + avalon_dcc_dir = os.path.dirname(os.path.dirname(__file__)) startup_js = "TB_sceneOpened.js" if os.getenv("TOONBOOM_GLOBAL_SCRIPT_LOCATION"):