Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Houdini: Publish any ROP node (Generic Creator) #2

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5b7fdfd
Implement Generic ROP publish from https://github.com/ynput/ayon-core…
BigRoy Jul 2, 2024
b5d5e09
Add argument to docstring
BigRoy Jul 3, 2024
421adbf
Merge branch 'develop' into enhancement/houdini_generic_publish
MustafaJafar Jul 5, 2024
a267cd2
Merge branch 'develop' into enhancement/houdini_generic_publish
BigRoy Jul 11, 2024
d6d7e9e
Merge branches 'enhancement/houdini_generic_publish' and 'enhancement…
BigRoy Jul 11, 2024
5b6f0ec
Add publish button
BigRoy Jul 11, 2024
46da010
Add help
BigRoy Jul 11, 2024
83e70d5
Merge branch 'develop' into enhancement/houdini_generic_publish
BigRoy Jul 17, 2024
e74903e
Merge branch 'develop' into enhancement/houdini_generic_publish
MustafaJafar Aug 21, 2024
7e9bbd0
Merge branch 'develop' of https://github.com/ynput/ayon-houdini into …
BigRoy Sep 20, 2024
6934ba6
Fix refactored merge conflict, skip non local renders like "local_no_…
BigRoy Sep 20, 2024
3791df1
Do not error on existing `ayon_self_publish` parm but log a warning
BigRoy Sep 20, 2024
6126888
Cosmetics
BigRoy Sep 20, 2024
c14710c
Elaborate TODO
BigRoy Sep 20, 2024
36c65ad
Merge branch 'develop' into enhancement/houdini_generic_publish
MustafaJafar Sep 23, 2024
5e5cef2
Merge branch 'develop' of https://github.com/ynput/ayon-houdini into …
BigRoy Oct 3, 2024
930615b
Merge branch 'enhancement/houdini_generic_publish' of https://github.…
BigRoy Oct 3, 2024
db57f1e
Cosmetics
BigRoy Oct 3, 2024
21ab75e
Move logic around, so we don't need to import the plugin.
BigRoy Oct 3, 2024
adf9236
Fix 0 and 1 integer values turning into `bool` incorrectly - now only…
BigRoy Oct 3, 2024
ddcf908
Update client/ayon_houdini/api/lib.py
BigRoy Oct 4, 2024
41dfc25
Fix auto-create for LABS Karma node
BigRoy Oct 4, 2024
fae1a89
Add todo
BigRoy Oct 4, 2024
3f70401
Shush ruff linter
BigRoy Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions client/ayon_houdini/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ def get_output_parameter(node):
return node.parm("outputimage")
elif node_type == "vray_renderer":
return node.parm("SettingsOutput_img_file_path")
elif node_type == "labs::karma::2.0":
return node.parm("picture")

if isinstance(node, hou.RopNode):
# Use the parm name fallback that SideFX applies for detecting output
# files from PDG/TOPs graphs for ROP nodes. See #ayon-core/692
parm_names = [
"vm_picture", "sopoutput", "dopoutput", "lopoutput", "picture",
"copoutput", "filename", "usdfile", "file", "output",
"outputfilepath", "outputimage", "outfile"
]
for name in parm_names:
parm = node.parm(name)
if parm:
return parm

raise TypeError("Node type '%s' not supported" % node_type)

Expand Down Expand Up @@ -1006,18 +1021,27 @@ def self_publish():
def add_self_publish_button(node):
"""Adds a self publish button to the rop node."""

parm_name = "ayon_self_publish"

label = os.environ.get("AYON_MENU_LABEL") or "AYON"
template = node.parmTemplateGroup()
existing = template.find(parm_name)
if existing:
log.warning(
f"Self publish parm already found on {node.path()}. "
"Skipping creation..."
)
return

button_parm = hou.ButtonParmTemplate(
"ayon_self_publish",
parm_name,
"{} Publish".format(label),
script_callback="from ayon_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)

Expand Down Expand Up @@ -1420,3 +1444,16 @@ def start_workfile_template_builder():
build_workfile_template(workfile_creation_enabled=True)
except TemplateProfileNotFound:
log.warning("Template profile not found. Skipping...")


@contextmanager
def no_auto_create_publishable():
value = os.environ.get("AYON_HOUDINI_AUTOCREATE")
os.environ["AYON_HOUDINI_AUTOCREATE"] = "0"
try:
yield
finally:
if value is None:
del os.environ["AYON_HOUDINI_AUTOCREATE"]
else:
os.environ["AYON_HOUDINI_AUTOCREATE"] = value
41 changes: 41 additions & 0 deletions client/ayon_houdini/api/node_wrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import hou

from ayon_core.pipeline import registered_host
from ayon_core.pipeline.create import CreateContext


def make_publishable(node):
# TODO: Can we make this imprinting much faster? Unfortunately
# CreateContext initialization is very slow.
host = registered_host()
context = CreateContext(host)

# Apply the instance creation to the node
context.create(
creator_identifier="io.ayon.creators.houdini.publish",
variant="__use_node_name__",
pre_create_data={
"node": node
}
)


# TODO: Move this choice of automatic 'imprint' to settings so studio can
# configure which nodes should get automatically imprinted on creation
# TODO: Do not import and reload the creator plugin file
from ayon_houdini.plugins.create import create_generic
BigRoy marked this conversation as resolved.
Show resolved Hide resolved
import importlib
importlib.reload(create_generic)
AUTO_CREATE_NODE_TYPES = set(
create_generic.CreateHoudiniGeneric.node_type_product_types.keys()
)


def autocreate_publishable(node):
# For now only consider RopNode
if not isinstance(node, hou.RopNode):
return

node_type = node.type().name()
if node_type in AUTO_CREATE_NODE_TYPES:
make_publishable(node)
24 changes: 16 additions & 8 deletions client/ayon_houdini/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
)
from ayon_core.lib import BoolDef

from .lib import imprint, read, lsattr, add_self_publish_button, render_rop
from .lib import (
imprint,
read,
lsattr,
add_self_publish_button,
no_auto_create_publishable,
render_rop
)
from .usd import get_ayon_entity_uri_from_representation_context


Expand Down Expand Up @@ -124,13 +131,14 @@ def create(self, product_name, instance_data, pre_create_data):

folder_path = instance_data["folderPath"]

instance_node = self.create_instance_node(
folder_path,
product_name,
"/out",
node_type,
pre_create_data
)
with no_auto_create_publishable():
instance_node = self.create_instance_node(
folder_path,
product_name,
"/out",
node_type,
pre_create_data
)

self.customize_node_look(instance_node)

Expand Down
Loading
Loading