mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Merge pull request #5621 from ynput/tests/houdini_rops-self-publish-button
This commit is contained in:
commit
b1dbbcd954
8 changed files with 170 additions and 4 deletions
|
|
@ -13,12 +13,19 @@ import six
|
||||||
from openpype.lib import StringTemplate
|
from openpype.lib import StringTemplate
|
||||||
from openpype.client import get_asset_by_name
|
from openpype.client import get_asset_by_name
|
||||||
from openpype.settings import get_current_project_settings
|
from openpype.settings import get_current_project_settings
|
||||||
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 (
|
from openpype.pipeline.context_tools import (
|
||||||
get_current_context_template_data,
|
get_current_context_template_data,
|
||||||
get_current_project_asset
|
get_current_project_asset
|
||||||
)
|
)
|
||||||
from openpype.widgets import popup
|
from openpype.widgets import popup
|
||||||
|
from openpype.tools.utils.host_tools import get_tool_by_name
|
||||||
|
from openpype.pipeline.create import CreateContext
|
||||||
|
|
||||||
import hou
|
import hou
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -847,3 +854,97 @@ def update_houdini_vars_context_dialog():
|
||||||
dialog.on_clicked.connect(update_houdini_vars_context)
|
dialog.on_clicked.connect(update_houdini_vars_context)
|
||||||
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
|
|
||||||
|
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,
|
||||||
|
)
|
||||||
|
publisher_window.show_and_publish(comment)
|
||||||
|
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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",
|
||||||
|
buttons=("Publish", "Cancel"),
|
||||||
|
title="Publish comment",
|
||||||
|
close_choice=1
|
||||||
|
)
|
||||||
|
|
||||||
|
if result:
|
||||||
|
return
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
for instance in context.instances:
|
||||||
|
node_path = instance.data.get("instance_node")
|
||||||
|
instance["active"] = node_path and node_path in inputs_paths
|
||||||
|
|
||||||
|
context.save_changes()
|
||||||
|
|
||||||
|
publisher_show_and_publish(comment)
|
||||||
|
|
||||||
|
|
||||||
|
def add_self_publish_button(node):
|
||||||
|
"""Adds a self publish button to the rop node."""
|
||||||
|
|
||||||
|
label = os.environ.get("AVALON_LABEL") or "OpenPype"
|
||||||
|
|
||||||
|
button_parm = hou.ButtonParmTemplate(
|
||||||
|
"ayon_self_publish",
|
||||||
|
"{} 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)
|
||||||
|
node.setParmTemplateGroup(template)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ from openpype.pipeline import (
|
||||||
CreatedInstance
|
CreatedInstance
|
||||||
)
|
)
|
||||||
from openpype.lib import BoolDef
|
from openpype.lib import BoolDef
|
||||||
from .lib import imprint, read, lsattr
|
from .lib import imprint, read, lsattr, add_self_publish_button
|
||||||
|
|
||||||
|
|
||||||
class OpenPypeCreatorError(CreatorError):
|
class OpenPypeCreatorError(CreatorError):
|
||||||
|
|
@ -168,6 +168,7 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase):
|
||||||
"""Base class for most of the Houdini creator plugins."""
|
"""Base class for most of the Houdini creator plugins."""
|
||||||
selected_nodes = []
|
selected_nodes = []
|
||||||
settings_name = None
|
settings_name = None
|
||||||
|
add_publish_button = False
|
||||||
|
|
||||||
def create(self, subset_name, instance_data, pre_create_data):
|
def create(self, subset_name, instance_data, pre_create_data):
|
||||||
try:
|
try:
|
||||||
|
|
@ -195,6 +196,10 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase):
|
||||||
self)
|
self)
|
||||||
self._add_instance_to_context(instance)
|
self._add_instance_to_context(instance)
|
||||||
self.imprint(instance_node, instance.data_to_store())
|
self.imprint(instance_node, instance.data_to_store())
|
||||||
|
|
||||||
|
if self.add_publish_button:
|
||||||
|
add_self_publish_button(instance_node)
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
except hou.Error as er:
|
except hou.Error as er:
|
||||||
|
|
@ -245,11 +250,14 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase):
|
||||||
key: changes[key].new_value
|
key: changes[key].new_value
|
||||||
for key in changes.changed_keys
|
for key in changes.changed_keys
|
||||||
}
|
}
|
||||||
|
# Update ParmTemplates
|
||||||
self.imprint(
|
self.imprint(
|
||||||
instance_node,
|
instance_node,
|
||||||
new_values,
|
new_values,
|
||||||
update=True
|
update=True
|
||||||
)
|
)
|
||||||
|
# Update values
|
||||||
|
instance_node.setParms(new_values)
|
||||||
|
|
||||||
def imprint(self, node, values, update=False):
|
def imprint(self, node, values, update=False):
|
||||||
# Never store instance node and instance id since that data comes
|
# Never store instance node and instance id since that data comes
|
||||||
|
|
@ -316,6 +324,12 @@ class HoudiniCreator(NewCreator, HoudiniCreatorBase):
|
||||||
def apply_settings(self, project_settings):
|
def apply_settings(self, project_settings):
|
||||||
"""Method called on initialization of plugin to apply settings."""
|
"""Method called on initialization of plugin to apply settings."""
|
||||||
|
|
||||||
|
# Apply General Settings
|
||||||
|
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
|
settings_name = self.settings_name
|
||||||
if settings_name is None:
|
if settings_name is None:
|
||||||
settings_name = self.__class__.__name__
|
settings_name = self.__class__.__name__
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"general": {
|
"general": {
|
||||||
|
"add_self_publish_button": false,
|
||||||
"update_houdini_var_context": {
|
"update_houdini_var_context": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"houdini_vars":[
|
"houdini_vars":[
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@
|
||||||
"collapsible": true,
|
"collapsible": true,
|
||||||
"is_group": true,
|
"is_group": true,
|
||||||
"children": [
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"key": "add_self_publish_button",
|
||||||
|
"label": "Add Self Publish Button"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "dict",
|
"type": "dict",
|
||||||
"collapsible": true,
|
"collapsible": true,
|
||||||
|
|
|
||||||
|
|
@ -388,6 +388,45 @@ class PublisherWindow(QtWidgets.QDialog):
|
||||||
def controller(self):
|
def controller(self):
|
||||||
return self._controller
|
return self._controller
|
||||||
|
|
||||||
|
def show_and_publish(self, comment=None):
|
||||||
|
"""Show the window and start publishing.
|
||||||
|
|
||||||
|
The method will reset controller and start the publishing afterwards.
|
||||||
|
|
||||||
|
Todos:
|
||||||
|
Move validations from '_on_publish_clicked' and change of
|
||||||
|
'comment' value in controller to controller so it can be
|
||||||
|
simplified.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
comment (Optional[str]): Comment to be set to publish.
|
||||||
|
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.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):
|
def make_sure_is_visible(self):
|
||||||
if self._window_is_visible:
|
if self._window_is_visible:
|
||||||
self.setWindowState(QtCore.Qt.WindowActive)
|
self.setWindowState(QtCore.Qt.WindowActive)
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,8 @@ class HostToolsHelper:
|
||||||
ILoadHost.validate_load_methods(host)
|
ILoadHost.validate_load_methods(host)
|
||||||
|
|
||||||
publisher_window = PublisherWindow(
|
publisher_window = PublisherWindow(
|
||||||
controller=controller, parent=parent or self._parent
|
controller=controller,
|
||||||
|
parent=parent or self._parent
|
||||||
)
|
)
|
||||||
self._publisher_tool = publisher_window
|
self._publisher_tool = publisher_window
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,10 @@ class UpdateHoudiniVarcontextModel(BaseSettingsModel):
|
||||||
|
|
||||||
|
|
||||||
class GeneralSettingsModel(BaseSettingsModel):
|
class GeneralSettingsModel(BaseSettingsModel):
|
||||||
|
add_self_publish_button: bool = Field(
|
||||||
|
False,
|
||||||
|
title="Add Self Publish Button"
|
||||||
|
)
|
||||||
update_houdini_var_context: UpdateHoudiniVarcontextModel = Field(
|
update_houdini_var_context: UpdateHoudiniVarcontextModel = Field(
|
||||||
default_factory=UpdateHoudiniVarcontextModel,
|
default_factory=UpdateHoudiniVarcontextModel,
|
||||||
title="Update Houdini Vars on context change"
|
title="Update Houdini Vars on context change"
|
||||||
|
|
@ -32,6 +36,7 @@ class GeneralSettingsModel(BaseSettingsModel):
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_GENERAL_SETTINGS = {
|
DEFAULT_GENERAL_SETTINGS = {
|
||||||
|
"add_self_publish_button": False,
|
||||||
"update_houdini_var_context": {
|
"update_houdini_var_context": {
|
||||||
"enabled": True,
|
"enabled": True,
|
||||||
"houdini_vars": [
|
"houdini_vars": [
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
__version__ = "0.1.4"
|
__version__ = "0.1.5"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue