Skip to content

Commit

Permalink
Implement Generic ROP publish from ynput/ayon-core#542
Browse files Browse the repository at this point in the history
  • Loading branch information
BigRoy committed Jul 2, 2024
1 parent 4a3f592 commit 5b7fdfd
Show file tree
Hide file tree
Showing 10 changed files with 883 additions and 16 deletions.
28 changes: 28 additions & 0 deletions client/ayon_houdini/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,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 @@ -1363,3 +1378,16 @@ def prompt_reset_context():
update_content_on_context_change()

dialog.deleteLater()


@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
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)
23 changes: 15 additions & 8 deletions client/ayon_houdini/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
)
from ayon_core.lib import BoolDef

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


SETTINGS_CATEGORY = "houdini"
Expand Down Expand Up @@ -122,13 +128,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

0 comments on commit 5b7fdfd

Please sign in to comment.