Skip to content

Commit

Permalink
Merge pull request #4 from nfa-vfxim/dev
Browse files Browse the repository at this point in the history
Added alembic to stage loading
  • Loading branch information
mervinvb authored Apr 16, 2024
2 parents 1bbc9b1 + d5d02c1 commit ac86b67
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
45 changes: 44 additions & 1 deletion hooks/tk-houdini_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ def generate_actions(self, sg_publish_data, actions, ui_area):
"description": "Import the Alembic cache file into a geometry network.",
}
)

if "stage_import" in actions:
action_instances.append(
{
"name": "stage_import",
"params": None,
"caption": "Stage import",
"description": "Import the Alembic cache file into the stage.",
}
)
if "file_cop" in actions:
action_instances.append(
{
Expand Down Expand Up @@ -232,6 +240,9 @@ def execute_action(self, name, params, sg_publish_data):
if name == "import":
self._import(path, sg_publish_data)

if name == "stage_import":
self._stage_import(path, sg_publish_data)

if name == "file_cop":
self._file_cop(path, sg_publish_data)

Expand Down Expand Up @@ -309,6 +320,38 @@ def _import(self, path, sg_publish_data):

##############################################################################################################

def _stage_import(self, path, sg_publish_data):
"""Import the supplied path as a geo/alembic sop.
:param str path: The path to the file to import.
:param dict sg_publish_data: The publish data for the supplied path.
"""

import hou

name = sg_publish_data.get("name", "alembic")
path = self.get_publish_path(sg_publish_data)

# houdini doesn't like UNC paths.
path = path.replace("\\", "/")

stage = hou.node("/stage")

sop_create_node = stage.createNode("sopcreate", name)
sop_create_node.allowEditingOfContents()

alembic_node = (
sop_create_node.node("sopnet").node("create").createNode("alembic", name)
)
alembic_node.parm("fileName").set(path)
alembic_node.parm("reload").pressButton()

try:
_show_node(sop_create_node)
except UnboundLocalError:
pass

def _file_sop(self, path, sg_publish_data):
"""Import the supplied path as a file sop.
Expand Down
33 changes: 33 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[tool.black]
line-length = 88

[tool.isort]
profile = "black"

[tool.ruff]
extend-select = [
"B",
"BLE",
"C4",
"ERA",
"I",
"ICN",
"INP",
"ISC",
"N",
"NPY",
"PGH",
"PIE",
"Q",
"RET",
"RSE",
"RUF",
"S",
"SIM",
"T20",
"TCH",
"TID",
"YTT",
]
show-fixes = true
target-version = "py37"

0 comments on commit ac86b67

Please sign in to comment.