From e5fab7d12169c4defc84ff06c8d7344046e03c34 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 4 Feb 2022 18:03:16 +0100 Subject: [PATCH] OP-2414 - merged Creators into one better importable --- openpype/hosts/harmony/api/__init__.py | 3 +- openpype/hosts/harmony/api/pipeline.py | 67 ------------------------ openpype/hosts/harmony/api/plugin.py | 70 ++++++++++++++++++++++++-- 3 files changed, 68 insertions(+), 72 deletions(-) diff --git a/openpype/hosts/harmony/api/__init__.py b/openpype/hosts/harmony/api/__init__.py index 286b8e3381..d78e04e83f 100644 --- a/openpype/hosts/harmony/api/__init__.py +++ b/openpype/hosts/harmony/api/__init__.py @@ -3,11 +3,11 @@ Anything that isn't defined here is INTERNAL and unreliable for external use. """ +from . import plugin from .pipeline import ( ls, install, - Creator, list_instances, remove_instance, select_instance, @@ -52,7 +52,6 @@ __all__ = [ # pipeline "ls", "install", - "Creator", "list_instances", "remove_instance", "select_instance", diff --git a/openpype/hosts/harmony/api/pipeline.py b/openpype/hosts/harmony/api/pipeline.py index f998403fb9..fc93d18ff5 100644 --- a/openpype/hosts/harmony/api/pipeline.py +++ b/openpype/hosts/harmony/api/pipeline.py @@ -319,73 +319,6 @@ def select_instance(instance): harmony.select_nodes([instance.get("uuid")]) -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, namespace, node, diff --git a/openpype/hosts/harmony/api/plugin.py b/openpype/hosts/harmony/api/plugin.py index 13a5625e72..9bcc49fd3f 100644 --- a/openpype/hosts/harmony/api/plugin.py +++ b/openpype/hosts/harmony/api/plugin.py @@ -1,6 +1,70 @@ -from openpype.hosts.harmony.api import Creator +import avalon.api from openpype.api import PypeCreatorMixin +import openpype.hosts.harmony.api as harmony -class Creator(PypeCreatorMixin, Creator): - pass +class Creator(PypeCreatorMixin, 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 \ No newline at end of file