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 different HDA products from different folder paths with the same product name #644

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"""Creator plugin for creating publishable Houdini Digital Assets."""
import ayon_api

from ayon_core.pipeline import CreatorError
from ayon_core.pipeline import (
CreatorError,
get_current_project_name
)
from ayon_houdini.api import plugin
import hou

Expand Down Expand Up @@ -56,8 +59,18 @@ def create_instance_node(
raise CreatorError(
"cannot create hda from node {}".format(to_hda))

# Pick a unique type name for HDA product per folder path per project.
type_name = (
"{project_name}{folder_path}_{node_name}".format(
project_name=get_current_project_name(),
folder_path=folder_path.replace("/","_"),
node_name=node_name
)
)

hda_node = to_hda.createDigitalAsset(
name=node_name,
name=type_name,
description=node_name,
hda_file_name="$HIP/{}.hda".format(node_name)
)
hda_node.layoutChildren()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ def load(self, context, name=None, namespace=None, data=None):
# Get the root node
obj = hou.node("/obj")

# Create a unique name
counter = 1
namespace = namespace or context["folder"]["name"]
formatted = "{}_{}".format(namespace, name) if namespace else name
node_name = "{0}_{1:03d}".format(formatted, counter)
node_name = "{}_{}".format(namespace, name) if namespace else name

hou.hda.installFile(file_path)
hda_node = obj.createNode(name, node_name)

# Get the type name from the HDA definition.
hda_defs = hou.hda.definitionsInFile(file_path)
for hda_def in hda_defs:
type_name = hda_def.nodeTypeName()

hda_node = obj.createNode(type_name, node_name)

self[:] = [hda_node]

Expand Down