From f6de6d07bc7e59575c54b81b531d165fae822fbf Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Thu, 14 Sep 2023 21:01:14 +0300 Subject: [PATCH 01/18] add self publish button --- openpype/hosts/houdini/api/lib.py | 62 ++++++++++++++++++++++++++++ openpype/hosts/houdini/api/plugin.py | 3 +- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index 75c7ff9fee..755368616b 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -649,3 +649,65 @@ def get_color_management_preferences(): "display": hou.Color.ocio_defaultDisplay(), "view": hou.Color.ocio_defaultView() } + + +def publisher_show_and_publish(): + """Open publisher window and trigger publishing action. """ + + from openpype.tools.utils.host_tools import get_tool_by_name + + main_window = get_main_window() + publisher_window = get_tool_by_name( + tool_name="publisher", + parent=main_window + ) + + publisher_window.set_current_tab("publish") + publisher_window.make_sure_is_visible() + publisher_window._reset_on_show = False + + publisher_window._controller.reset() + publisher_window._controller.publish() + + +def self_publish(): + """Self publish from ROP nodes. """ + from openpype.pipeline import registered_host + from openpype.pipeline.create import CreateContext + + current_node = hou.node(".").path() + + host = registered_host() + context = CreateContext(host, reset=True) + + for instance in context.instances: + node_path = instance.data.get("instance_node") + if not node_path: + continue + print(node_path) + + if current_node == node_path: + instance["active"] = True + else: + instance["active"] = False + + context.save_changes() + publisher_show_and_publish() + +def add_self_publish_button(node): + """Adds a self publish button in the rop node. """ + label = os.environ.get("AVALON_LABEL") or "OpenPype" + + button_parm = hou.ButtonParmTemplate( + "{}_publish".format(label.lower()), + "{} Publish".format(label), + script_callback="from openpype.hosts.houdini.api.lib import " + "self_publish; self_publish()", + script_callback_language=hou.scriptLanguage.Python, + join_with_next=True + ) + + template = node.parmTemplateGroup() + template.insertBefore((0,), button_parm) + # parm_group.append(button_parm) + node.setParmTemplateGroup(template) diff --git a/openpype/hosts/houdini/api/plugin.py b/openpype/hosts/houdini/api/plugin.py index 730a627dc3..756b33f7f7 100644 --- a/openpype/hosts/houdini/api/plugin.py +++ b/openpype/hosts/houdini/api/plugin.py @@ -13,7 +13,7 @@ from openpype.pipeline import ( CreatedInstance ) from openpype.lib import BoolDef -from .lib import imprint, read, lsattr +from .lib import imprint, read, lsattr, add_self_publish_button class OpenPypeCreatorError(CreatorError): @@ -194,6 +194,7 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase): self) self._add_instance_to_context(instance) imprint(instance_node, instance.data_to_store()) + add_self_publish_button(instance_node) return instance except hou.Error as er: From dc065171f9452bae9994835e3bdcacdae12f431b Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Thu, 14 Sep 2023 21:16:17 +0300 Subject: [PATCH 02/18] resolve hound --- openpype/hosts/houdini/api/lib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index 755368616b..a91f319ae8 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -694,6 +694,7 @@ def self_publish(): context.save_changes() publisher_show_and_publish() + def add_self_publish_button(node): """Adds a self publish button in the rop node. """ label = os.environ.get("AVALON_LABEL") or "OpenPype" From 2d8034ae77bccb4dd54438dad023bd3b15e7e93d Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Thu, 14 Sep 2023 23:36:16 +0300 Subject: [PATCH 03/18] BigRoy's Comment --- openpype/hosts/houdini/api/lib.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index a91f319ae8..c175b32b83 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -10,8 +10,14 @@ import json import six from openpype.client import get_asset_by_name -from openpype.pipeline import get_current_project_name, get_current_asset_name +from openpype.pipeline import ( + get_current_project_name, + get_current_asset_name, + registered_host +) from openpype.pipeline.context_tools import get_current_project_asset +from openpype.tools.utils.host_tools import get_tool_by_name +from openpype.pipeline.create import CreateContext import hou @@ -652,9 +658,7 @@ def get_color_management_preferences(): def publisher_show_and_publish(): - """Open publisher window and trigger publishing action. """ - - from openpype.tools.utils.host_tools import get_tool_by_name + """Open publisher window and trigger publishing action.""" main_window = get_main_window() publisher_window = get_tool_by_name( @@ -671,9 +675,7 @@ def publisher_show_and_publish(): def self_publish(): - """Self publish from ROP nodes. """ - from openpype.pipeline import registered_host - from openpype.pipeline.create import CreateContext + """Self publish from ROP nodes.""" current_node = hou.node(".").path() @@ -684,19 +686,16 @@ def self_publish(): node_path = instance.data.get("instance_node") if not node_path: continue - print(node_path) - if current_node == node_path: - instance["active"] = True - else: - instance["active"] = False + instance["active"] = current_node == node_path context.save_changes() publisher_show_and_publish() def add_self_publish_button(node): - """Adds a self publish button in the rop node. """ + """Adds a self publish button in the rop node.""" + label = os.environ.get("AVALON_LABEL") or "OpenPype" button_parm = hou.ButtonParmTemplate( @@ -710,5 +709,4 @@ def add_self_publish_button(node): template = node.parmTemplateGroup() template.insertBefore((0,), button_parm) - # parm_group.append(button_parm) node.setParmTemplateGroup(template) From a4f46380657dc24924627dc877cfa59312d572b0 Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Fri, 15 Sep 2023 10:35:50 +0300 Subject: [PATCH 04/18] add publish comment --- openpype/hosts/houdini/api/lib.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index c175b32b83..b6b551a592 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -687,7 +687,20 @@ def self_publish(): if not node_path: continue - instance["active"] = current_node == node_path + active = current_node == node_path + if not active: + continue + + instance["active"] = active + + result, comment = hou.ui.readInput( + "Add Publish Note", + buttons=("Ok", "Cancel"), + title="Publish Note", + close_choice=1 + ) + if not result: + instance.data["comment"] = comment context.save_changes() publisher_show_and_publish() From e48090757f6f7c9b88abc8779d16e5f26078db87 Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Fri, 15 Sep 2023 12:15:15 +0300 Subject: [PATCH 05/18] fix bug - disable other instances --- openpype/hosts/houdini/api/lib.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index b6b551a592..7e346d7285 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -688,19 +688,17 @@ def self_publish(): continue active = current_node == node_path - if not active: - continue - instance["active"] = active - result, comment = hou.ui.readInput( - "Add Publish Note", - buttons=("Ok", "Cancel"), - title="Publish Note", - close_choice=1 - ) - if not result: - instance.data["comment"] = comment + if active: + result, comment = hou.ui.readInput( + "Add Publish Note", + buttons=("Ok", "Cancel"), + title="Publish Note", + close_choice=1 + ) + if not result: + instance.data["comment"] = comment context.save_changes() publisher_show_and_publish() From 2f5494cc76e25e4e5b7bdc3e743da0e279d8c256 Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Fri, 15 Sep 2023 17:02:49 +0300 Subject: [PATCH 06/18] make few publisher attributes and methods public --- openpype/hosts/houdini/api/lib.py | 34 +++++++++++++++--------------- openpype/tools/publisher/window.py | 14 ++++++++++++ openpype/tools/utils/host_tools.py | 12 +++++++---- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index 7e346d7285..688916a507 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -657,21 +657,22 @@ def get_color_management_preferences(): } -def publisher_show_and_publish(): +def publisher_show_and_publish(comment = ""): """Open publisher window and trigger publishing action.""" main_window = get_main_window() publisher_window = get_tool_by_name( tool_name="publisher", - parent=main_window + parent=main_window, + reset_on_show=False ) publisher_window.set_current_tab("publish") publisher_window.make_sure_is_visible() - publisher_window._reset_on_show = False - - publisher_window._controller.reset() - publisher_window._controller.publish() + publisher_window.reset_on_show = False + publisher_window.set_comment_input_text(comment) + publisher_window.reset() + publisher_window.click_publish() def self_publish(): @@ -689,19 +690,18 @@ def self_publish(): active = current_node == node_path instance["active"] = active - - if active: - result, comment = hou.ui.readInput( - "Add Publish Note", - buttons=("Ok", "Cancel"), - title="Publish Note", - close_choice=1 - ) - if not result: - instance.data["comment"] = comment + hou.node(node_path).parm("active").set(active) context.save_changes() - publisher_show_and_publish() + + result, comment = hou.ui.readInput( + "Add Publish Note", + buttons=("Ok", "Cancel"), + title="Publish Note", + close_choice=1 + ) + + publisher_show_and_publish(comment) def add_self_publish_button(node): diff --git a/openpype/tools/publisher/window.py b/openpype/tools/publisher/window.py index 39e78c01bb..9214c0a43f 100644 --- a/openpype/tools/publisher/window.py +++ b/openpype/tools/publisher/window.py @@ -388,6 +388,20 @@ class PublisherWindow(QtWidgets.QDialog): def controller(self): return self._controller + @property + def reset_on_show(self): + return self._reset_on_show + + @reset_on_show.setter + def reset_on_show(self, value): + self._reset_on_show = value + + def set_comment_input_text(self, text=""): + self._comment_input.setText(text) + + def click_publish(self): + self._on_publish_clicked() + def make_sure_is_visible(self): if self._window_is_visible: self.setWindowState(QtCore.Qt.WindowActive) diff --git a/openpype/tools/utils/host_tools.py b/openpype/tools/utils/host_tools.py index 2ebc973a47..3e891e1847 100644 --- a/openpype/tools/utils/host_tools.py +++ b/openpype/tools/utils/host_tools.py @@ -261,7 +261,7 @@ class HostToolsHelper: dialog.activateWindow() dialog.showNormal() - def get_publisher_tool(self, parent=None, controller=None): + def get_publisher_tool(self, parent=None, controller=None, reset_on_show=None): """Create, cache and return publisher window.""" if self._publisher_tool is None: @@ -271,15 +271,19 @@ class HostToolsHelper: ILoadHost.validate_load_methods(host) publisher_window = PublisherWindow( - controller=controller, parent=parent or self._parent + controller=controller, + parent=parent or self._parent, + reset_on_show=reset_on_show ) self._publisher_tool = publisher_window return self._publisher_tool - def show_publisher_tool(self, parent=None, controller=None, tab=None): + def show_publisher_tool( + self, parent=None, controller=None, reset_on_show=None, tab=None + ): with qt_app_context(): - window = self.get_publisher_tool(parent, controller) + window = self.get_publisher_tool(parent, controller, reset_on_show) if tab: window.set_current_tab(tab) window.make_sure_is_visible() From 53a626e9ac69cf2239e527a7bc4c6154102374c6 Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Fri, 15 Sep 2023 17:04:43 +0300 Subject: [PATCH 07/18] resolve hound --- openpype/hosts/houdini/api/lib.py | 2 +- openpype/tools/utils/host_tools.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index 688916a507..0bde308263 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -657,7 +657,7 @@ def get_color_management_preferences(): } -def publisher_show_and_publish(comment = ""): +def publisher_show_and_publish(comment=""): """Open publisher window and trigger publishing action.""" main_window = get_main_window() diff --git a/openpype/tools/utils/host_tools.py b/openpype/tools/utils/host_tools.py index 3e891e1847..6885fb86c1 100644 --- a/openpype/tools/utils/host_tools.py +++ b/openpype/tools/utils/host_tools.py @@ -261,7 +261,9 @@ class HostToolsHelper: dialog.activateWindow() dialog.showNormal() - def get_publisher_tool(self, parent=None, controller=None, reset_on_show=None): + def get_publisher_tool( + self, parent=None, controller=None, reset_on_show=None + ): """Create, cache and return publisher window.""" if self._publisher_tool is None: From 4f52c70093217d79ad542e88a6078b5bb3be7df6 Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Fri, 22 Sep 2023 12:06:37 +0300 Subject: [PATCH 08/18] make self publish button optional --- openpype/hosts/houdini/api/plugin.py | 11 ++++++++++- .../defaults/project_settings/houdini.json | 3 +++ .../projects_schema/schema_project_houdini.json | 4 ++++ .../schemas/schema_houdini_general.json | 14 ++++++++++++++ server_addon/houdini/server/settings/general.py | 15 +++++++++++++++ server_addon/houdini/server/settings/main.py | 9 +++++++++ server_addon/houdini/server/version.py | 2 +- 7 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 openpype/settings/entities/schemas/projects_schema/schemas/schema_houdini_general.json create mode 100644 server_addon/houdini/server/settings/general.py diff --git a/openpype/hosts/houdini/api/plugin.py b/openpype/hosts/houdini/api/plugin.py index 756b33f7f7..8670103a81 100644 --- a/openpype/hosts/houdini/api/plugin.py +++ b/openpype/hosts/houdini/api/plugin.py @@ -168,6 +168,7 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase): """Base class for most of the Houdini creator plugins.""" selected_nodes = [] settings_name = None + _add_self_publish_button = False def create(self, subset_name, instance_data, pre_create_data): try: @@ -194,7 +195,10 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase): self) self._add_instance_to_context(instance) imprint(instance_node, instance.data_to_store()) - add_self_publish_button(instance_node) + + if self._add_self_publish_button: + add_self_publish_button(instance_node) + return instance except hou.Error as er: @@ -300,6 +304,11 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase): def apply_settings(self, project_settings): """Method called on initialization of plugin to apply settings.""" + # Apply General Settings + self._add_self_publish_button = \ + project_settings["houdini"]["general"]["add_self_publish_button"] + + # Apply Creator Settings settings_name = self.settings_name if settings_name is None: settings_name = self.__class__.__name__ diff --git a/openpype/settings/defaults/project_settings/houdini.json b/openpype/settings/defaults/project_settings/houdini.json index 5392fc34dd..f60f5f2761 100644 --- a/openpype/settings/defaults/project_settings/houdini.json +++ b/openpype/settings/defaults/project_settings/houdini.json @@ -1,4 +1,7 @@ { + "general": { + "add_self_publish_button": false + }, "imageio": { "activate_host_color_management": true, "ocio_config": { diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_houdini.json b/openpype/settings/entities/schemas/projects_schema/schema_project_houdini.json index 7f782e3647..d4d0565ec9 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_houdini.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_houdini.json @@ -5,6 +5,10 @@ "label": "Houdini", "is_file": true, "children": [ + { + "type": "schema", + "name": "schema_houdini_general" + }, { "key": "imageio", "type": "dict", diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_houdini_general.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_houdini_general.json new file mode 100644 index 0000000000..a69501c98c --- /dev/null +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_houdini_general.json @@ -0,0 +1,14 @@ +{ + "type": "dict", + "key": "general", + "label": "General", + "collapsible": true, + "is_group": true, + "children": [ + { + "type": "boolean", + "key": "add_self_publish_button", + "label": "Add Self Publish Button" + } + ] +} diff --git a/server_addon/houdini/server/settings/general.py b/server_addon/houdini/server/settings/general.py new file mode 100644 index 0000000000..9c19acd6c9 --- /dev/null +++ b/server_addon/houdini/server/settings/general.py @@ -0,0 +1,15 @@ +from pydantic import Field +from ayon_server.settings import BaseSettingsModel + + + +class GeneralSettingsModel(BaseSettingsModel): + add_self_publish_button: bool = Field( + False, + title="Add Self Publish Button" + ) + + +DEFAULT_GENERAL_SETTINGS = { + "add_self_publish_button": False +} diff --git a/server_addon/houdini/server/settings/main.py b/server_addon/houdini/server/settings/main.py index fdb6838f5c..8de8d8aeae 100644 --- a/server_addon/houdini/server/settings/main.py +++ b/server_addon/houdini/server/settings/main.py @@ -5,6 +5,10 @@ from ayon_server.settings import ( MultiplatformPathListModel, ) +from .general import ( + GeneralSettingsModel, + DEFAULT_GENERAL_SETTINGS +) from .imageio import HoudiniImageIOModel from .publish_plugins import ( PublishPluginsModel, @@ -52,6 +56,10 @@ class ShelvesModel(BaseSettingsModel): class HoudiniSettings(BaseSettingsModel): + general: GeneralSettingsModel = Field( + default_factory=GeneralSettingsModel, + title="General" + ) imageio: HoudiniImageIOModel = Field( default_factory=HoudiniImageIOModel, title="Color Management (ImageIO)" @@ -73,6 +81,7 @@ class HoudiniSettings(BaseSettingsModel): DEFAULT_VALUES = { + "general" : DEFAULT_GENERAL_SETTINGS, "shelves": [], "create": DEFAULT_HOUDINI_CREATE_SETTINGS, "publish": DEFAULT_HOUDINI_PUBLISH_SETTINGS diff --git a/server_addon/houdini/server/version.py b/server_addon/houdini/server/version.py index ae7362549b..bbab0242f6 100644 --- a/server_addon/houdini/server/version.py +++ b/server_addon/houdini/server/version.py @@ -1 +1 @@ -__version__ = "0.1.3" +__version__ = "0.1.4" From 792e92ca44a22ad4318bc8ba330024719b86e068 Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Fri, 22 Sep 2023 12:08:58 +0300 Subject: [PATCH 09/18] resolve hound --- server_addon/houdini/server/settings/general.py | 1 - server_addon/houdini/server/settings/main.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/server_addon/houdini/server/settings/general.py b/server_addon/houdini/server/settings/general.py index 9c19acd6c9..ce20a30e7c 100644 --- a/server_addon/houdini/server/settings/general.py +++ b/server_addon/houdini/server/settings/general.py @@ -2,7 +2,6 @@ from pydantic import Field from ayon_server.settings import BaseSettingsModel - class GeneralSettingsModel(BaseSettingsModel): add_self_publish_button: bool = Field( False, diff --git a/server_addon/houdini/server/settings/main.py b/server_addon/houdini/server/settings/main.py index 8de8d8aeae..1a3968bf28 100644 --- a/server_addon/houdini/server/settings/main.py +++ b/server_addon/houdini/server/settings/main.py @@ -81,7 +81,7 @@ class HoudiniSettings(BaseSettingsModel): DEFAULT_VALUES = { - "general" : DEFAULT_GENERAL_SETTINGS, + "general": DEFAULT_GENERAL_SETTINGS, "shelves": [], "create": DEFAULT_HOUDINI_CREATE_SETTINGS, "publish": DEFAULT_HOUDINI_PUBLISH_SETTINGS From ed7b321f640617bc529d548b613186b4fbd3b7f8 Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Fri, 22 Sep 2023 16:18:04 +0300 Subject: [PATCH 10/18] BigRoy's comments --- openpype/hosts/houdini/api/lib.py | 19 +++++++++++-------- openpype/hosts/houdini/api/plugin.py | 6 +++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index 27f5476894..0e5aa1e74a 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -776,6 +776,16 @@ def publisher_show_and_publish(comment=""): def self_publish(): """Self publish from ROP nodes.""" + result, comment = hou.ui.readInput( + "Add Publish Comment", + buttons=("Publish", "Cancel"), + title="Publish comment", + close_choice=1 + ) + + if result: + return + current_node = hou.node(".").path() host = registered_host() @@ -792,18 +802,11 @@ def self_publish(): context.save_changes() - result, comment = hou.ui.readInput( - "Add Publish Note", - buttons=("Ok", "Cancel"), - title="Publish Note", - close_choice=1 - ) - publisher_show_and_publish(comment) def add_self_publish_button(node): - """Adds a self publish button in the rop node.""" + """Adds a self publish button to the rop node.""" label = os.environ.get("AVALON_LABEL") or "OpenPype" diff --git a/openpype/hosts/houdini/api/plugin.py b/openpype/hosts/houdini/api/plugin.py index 8670103a81..2cd7ff83e3 100644 --- a/openpype/hosts/houdini/api/plugin.py +++ b/openpype/hosts/houdini/api/plugin.py @@ -168,7 +168,7 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase): """Base class for most of the Houdini creator plugins.""" selected_nodes = [] settings_name = None - _add_self_publish_button = False + add_publish_button = False def create(self, subset_name, instance_data, pre_create_data): try: @@ -196,7 +196,7 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase): self._add_instance_to_context(instance) imprint(instance_node, instance.data_to_store()) - if self._add_self_publish_button: + if self.add_publish_button: add_self_publish_button(instance_node) return instance @@ -305,7 +305,7 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase): """Method called on initialization of plugin to apply settings.""" # Apply General Settings - self._add_self_publish_button = \ + self.add_publish_button = \ project_settings["houdini"]["general"]["add_self_publish_button"] # Apply Creator Settings From 1cd3a9e701cb6cea04844c6dec7a7672c8a2758d Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Fri, 22 Sep 2023 23:00:58 +0300 Subject: [PATCH 11/18] make self publish to publish input dependencies --- openpype/hosts/houdini/api/lib.py | 39 ++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index 0e5aa1e74a..3780087bd0 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -773,8 +773,37 @@ def publisher_show_and_publish(comment=""): publisher_window.click_publish() +def find_rop_input_dependencies(input_tuple): + """Self publish from ROP nodes. + + Arguments: + tuple (hou.RopNode.inputDependencies) which can be a nested tuples + represents the input dependencies of the ROP node, consisting of ROPs, + and the frames that need to be be rendered prior to rendering the ROP. + + Returns: + list of the RopNode.path() that can be found inside + the input tuple. + """ + + out_list = [] + if isinstance(input_tuple[0], hou.RopNode): + return input_tuple[0].path() + + if isinstance(input_tuple[0], tuple): + for item in input_tuple: + out_list.append(find_rop_input_dependencies(item)) + + return out_list + + def self_publish(): - """Self publish from ROP nodes.""" + """Self publish from ROP nodes. + + Firstly, it gets the node and its dependencies. + Then, it deactivates all other ROPs + And finaly, it triggers the publishing action. + """ result, comment = hou.ui.readInput( "Add Publish Comment", @@ -786,7 +815,11 @@ def self_publish(): if result: return - current_node = hou.node(".").path() + current_node = hou.node(".") + inputs_paths = find_rop_input_dependencies( + current_node.inputDependencies() + ) + inputs_paths.append(current_node.path()) host = registered_host() context = CreateContext(host, reset=True) @@ -796,7 +829,7 @@ def self_publish(): if not node_path: continue - active = current_node == node_path + active = node_path in inputs_paths instance["active"] = active hou.node(node_path).parm("active").set(active) From 8ee57bd3a1e030f32f85b0c409e44d09e2e0c9bb Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Wed, 11 Oct 2023 23:57:42 +0300 Subject: [PATCH 12/18] bugfix update instance parameters values on update_instances --- openpype/hosts/houdini/api/lib.py | 1 - openpype/hosts/houdini/api/plugin.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index 3b45914b19..6fa8b02735 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -932,7 +932,6 @@ def self_publish(): active = node_path in inputs_paths instance["active"] = active - hou.node(node_path).parm("active").set(active) context.save_changes() diff --git a/openpype/hosts/houdini/api/plugin.py b/openpype/hosts/houdini/api/plugin.py index c82ba11114..5102b64644 100644 --- a/openpype/hosts/houdini/api/plugin.py +++ b/openpype/hosts/houdini/api/plugin.py @@ -250,11 +250,14 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase): key: changes[key].new_value for key in changes.changed_keys } + # Update ParmTemplates self.imprint( instance_node, new_values, update=True ) + # Update values + instance_node.setParms(new_values) def imprint(self, node, values, update=False): # Never store instance node and instance id since that data comes From 27106bcc724b8db6bdf739d33d9fd9700dfc2f22 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 17 Oct 2023 14:12:57 +0200 Subject: [PATCH 13/18] moved show and publish logic to publisher window --- openpype/hosts/houdini/api/lib.py | 17 +++++-------- openpype/tools/publisher/window.py | 41 +++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index 6fa8b02735..8863570966 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -856,22 +856,19 @@ def update_houdini_vars_context_dialog(): dialog.show() -def publisher_show_and_publish(comment=""): - """Open publisher window and trigger publishing action.""" +def publisher_show_and_publish(comment=None): + """Open publisher window and trigger publishing action. + + Args: + comment (Optional[str]): Comment to set in publisher window. + """ main_window = get_main_window() publisher_window = get_tool_by_name( tool_name="publisher", parent=main_window, - reset_on_show=False ) - - publisher_window.set_current_tab("publish") - publisher_window.make_sure_is_visible() - publisher_window.reset_on_show = False - publisher_window.set_comment_input_text(comment) - publisher_window.reset() - publisher_window.click_publish() + publisher_window.show_and_pubish(comment) def find_rop_input_dependencies(input_tuple): diff --git a/openpype/tools/publisher/window.py b/openpype/tools/publisher/window.py index 9214c0a43f..af6d7371b1 100644 --- a/openpype/tools/publisher/window.py +++ b/openpype/tools/publisher/window.py @@ -388,20 +388,43 @@ class PublisherWindow(QtWidgets.QDialog): def controller(self): return self._controller - @property - def reset_on_show(self): - return self._reset_on_show + def show_and_publish(self, comment=None): + """Show the window and start publishing. - @reset_on_show.setter - def reset_on_show(self, value): - self._reset_on_show = value + The method will reset controller and start the publishing afterwards. - def set_comment_input_text(self, text=""): - self._comment_input.setText(text) + Todos: + Move validations from '_on_publish_clicked' and change of + 'comment' value in controller to controller so it can be + simplified. - def click_publish(self): + Args: + comment (Optional[str]): Comment to be set to publish. + If is set to 'None' a comment is not changed at all. + """ + + if comment is not None: + self.set_comment(comment) + self._reset_on_show = False + self.make_sure_is_visible() + # Reset controller + self._controller.reset() + # Fake publish click to trigger save validation and propagate + # comment to controller self._on_publish_clicked() + def set_comment(self, comment): + """Change comment text. + + Todos: + Be able to set the comment via controller. + + Args: + comment (str): Comment text. + """ + + self._comment_input.setText(comment) + def make_sure_is_visible(self): if self._window_is_visible: self.setWindowState(QtCore.Qt.WindowActive) From 0f9c30378ec49babc463b20e46bec07dca56020b Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 17 Oct 2023 14:26:14 +0200 Subject: [PATCH 14/18] revert 'get_publisher_tool' and 'show_publisher_tool' arguments --- openpype/tools/utils/host_tools.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/openpype/tools/utils/host_tools.py b/openpype/tools/utils/host_tools.py index 5f538fe45b..cc20774349 100644 --- a/openpype/tools/utils/host_tools.py +++ b/openpype/tools/utils/host_tools.py @@ -286,9 +286,7 @@ class HostToolsHelper: dialog.activateWindow() dialog.showNormal() - def get_publisher_tool( - self, parent=None, controller=None, reset_on_show=None - ): + def get_publisher_tool(self, parent=None, controller=None): """Create, cache and return publisher window.""" if self._publisher_tool is None: @@ -299,18 +297,15 @@ class HostToolsHelper: publisher_window = PublisherWindow( controller=controller, - parent=parent or self._parent, - reset_on_show=reset_on_show + parent=parent or self._parent ) self._publisher_tool = publisher_window return self._publisher_tool - def show_publisher_tool( - self, parent=None, controller=None, reset_on_show=None, tab=None - ): + def show_publisher_tool(self, parent=None, controller=None, tab=None): with qt_app_context(): - window = self.get_publisher_tool(parent, controller, reset_on_show) + window = self.get_publisher_tool(parent, controller) if tab: window.set_current_tab(tab) window.make_sure_is_visible() From e6ac57b35fa4ea51bfcde3e844660e60b95cc97f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= <33513211+antirotor@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:11:45 +0200 Subject: [PATCH 15/18] Update openpype/hosts/houdini/api/lib.py Co-authored-by: Roy Nieterau --- openpype/hosts/houdini/api/lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index 8863570966..e4b9d70d57 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -868,7 +868,7 @@ def publisher_show_and_publish(comment=None): tool_name="publisher", parent=main_window, ) - publisher_window.show_and_pubish(comment) + publisher_window.show_and_publish(comment) def find_rop_input_dependencies(input_tuple): From 13159c48890e24734da1390edd87d578aa98f640 Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Tue, 17 Oct 2023 17:29:27 +0300 Subject: [PATCH 16/18] Jakub comments --- openpype/hosts/houdini/api/lib.py | 8 ++------ openpype/hosts/houdini/api/plugin.py | 5 +++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/houdini/api/lib.py b/openpype/hosts/houdini/api/lib.py index e4b9d70d57..f258dda36e 100644 --- a/openpype/hosts/houdini/api/lib.py +++ b/openpype/hosts/houdini/api/lib.py @@ -924,11 +924,7 @@ def self_publish(): for instance in context.instances: node_path = instance.data.get("instance_node") - if not node_path: - continue - - active = node_path in inputs_paths - instance["active"] = active + instance["active"] = node_path and node_path in inputs_paths context.save_changes() @@ -941,7 +937,7 @@ def add_self_publish_button(node): label = os.environ.get("AVALON_LABEL") or "OpenPype" button_parm = hou.ButtonParmTemplate( - "{}_publish".format(label.lower()), + "ayon_self_publish", "{} Publish".format(label), script_callback="from openpype.hosts.houdini.api.lib import " "self_publish; self_publish()", diff --git a/openpype/hosts/houdini/api/plugin.py b/openpype/hosts/houdini/api/plugin.py index 5102b64644..d79ccc71bd 100644 --- a/openpype/hosts/houdini/api/plugin.py +++ b/openpype/hosts/houdini/api/plugin.py @@ -325,8 +325,9 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase): """Method called on initialization of plugin to apply settings.""" # Apply General Settings - self.add_publish_button = \ - project_settings["houdini"]["general"]["add_self_publish_button"] + houdini_general_settings = project_settings["houdini"]["general"] + self.add_publish_button = houdini_general_settings.get( + "add_self_publish_button", False) # Apply Creator Settings settings_name = self.settings_name From 0b02a97e5fabbf34136c6ebb5957c4930aea971c Mon Sep 17 00:00:00 2001 From: Mustafa-Zarkash Date: Tue, 17 Oct 2023 17:40:45 +0300 Subject: [PATCH 17/18] bump houdini addon version --- server_addon/houdini/server/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server_addon/houdini/server/version.py b/server_addon/houdini/server/version.py index bbab0242f6..1276d0254f 100644 --- a/server_addon/houdini/server/version.py +++ b/server_addon/houdini/server/version.py @@ -1 +1 @@ -__version__ = "0.1.4" +__version__ = "0.1.5" From 863ed821cad4a8544e6d37c272b70acdf852683d Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 18 Oct 2023 10:04:45 +0200 Subject: [PATCH 18/18] change '_reset_on_first_show' to 'False' on show and publish --- openpype/tools/publisher/window.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpype/tools/publisher/window.py b/openpype/tools/publisher/window.py index af6d7371b1..312cf1dd5c 100644 --- a/openpype/tools/publisher/window.py +++ b/openpype/tools/publisher/window.py @@ -403,9 +403,11 @@ class PublisherWindow(QtWidgets.QDialog): If is set to 'None' a comment is not changed at all. """ + self._reset_on_show = False + self._reset_on_first_show = False + if comment is not None: self.set_comment(comment) - self._reset_on_show = False self.make_sure_is_visible() # Reset controller self._controller.reset()