This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4588 from ynput/feature/OP-3129_houdini-bgeo-publ…
…ishing
- Loading branch information
Showing
16 changed files
with
228 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Creator plugin for creating pointcache bgeo files.""" | ||
from openpype.hosts.houdini.api import plugin | ||
from openpype.pipeline import CreatedInstance, CreatorError | ||
from openpype.lib import EnumDef | ||
|
||
|
||
class CreateBGEO(plugin.HoudiniCreator): | ||
"""BGEO pointcache creator.""" | ||
identifier = "io.openpype.creators.houdini.bgeo" | ||
label = "BGEO PointCache" | ||
family = "pointcache" | ||
icon = "gears" | ||
|
||
def create(self, subset_name, instance_data, pre_create_data): | ||
import hou | ||
|
||
instance_data.pop("active", None) | ||
|
||
instance_data.update({"node_type": "geometry"}) | ||
|
||
instance = super(CreateBGEO, self).create( | ||
subset_name, | ||
instance_data, | ||
pre_create_data) # type: CreatedInstance | ||
|
||
instance_node = hou.node(instance.get("instance_node")) | ||
|
||
file_path = "{}{}".format( | ||
hou.text.expandString("$HIP/pyblish/"), | ||
"{}.$F4.{}".format( | ||
subset_name, | ||
pre_create_data.get("bgeo_type") or "bgeo.sc") | ||
) | ||
parms = { | ||
"sopoutput": file_path | ||
} | ||
|
||
instance_node.parm("trange").set(1) | ||
if self.selected_nodes: | ||
# if selection is on SOP level, use it | ||
if isinstance(self.selected_nodes[0], hou.SopNode): | ||
parms["soppath"] = self.selected_nodes[0].path() | ||
else: | ||
# try to find output node with the lowest index | ||
outputs = [ | ||
child for child in self.selected_nodes[0].children() | ||
if child.type().name() == "output" | ||
] | ||
if not outputs: | ||
instance_node.setParms(parms) | ||
raise CreatorError(( | ||
"Missing output node in SOP level for the selection. " | ||
"Please select correct SOP path in created instance." | ||
)) | ||
outputs.sort(key=lambda output: output.evalParm("outputidx")) | ||
parms["soppath"] = outputs[0].path() | ||
|
||
instance_node.setParms(parms) | ||
|
||
def get_pre_create_attr_defs(self): | ||
attrs = super().get_pre_create_attr_defs() | ||
bgeo_enum = [ | ||
{ | ||
"value": "bgeo", | ||
"label": "uncompressed bgeo (.bgeo)" | ||
}, | ||
{ | ||
"value": "bgeosc", | ||
"label": "BLOSC compressed bgeo (.bgeosc)" | ||
}, | ||
{ | ||
"value": "bgeo.sc", | ||
"label": "BLOSC compressed bgeo (.bgeo.sc)" | ||
}, | ||
{ | ||
"value": "bgeo.gz", | ||
"label": "GZ compressed bgeo (.bgeo.gz)" | ||
}, | ||
{ | ||
"value": "bgeo.lzma", | ||
"label": "LZMA compressed bgeo (.bgeo.lzma)" | ||
}, | ||
{ | ||
"value": "bgeo.bz2", | ||
"label": "BZip2 compressed bgeo (.bgeo.bz2)" | ||
} | ||
] | ||
|
||
return attrs + [ | ||
EnumDef("bgeo_type", bgeo_enum, label="BGEO Options"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
openpype/hosts/houdini/plugins/publish/collect_pointcache_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Collector for pointcache types. | ||
This will add additional family to pointcache instance based on | ||
the creator_identifier parameter. | ||
""" | ||
import pyblish.api | ||
|
||
|
||
class CollectPointcacheType(pyblish.api.InstancePlugin): | ||
"""Collect data type for pointcache instance.""" | ||
|
||
order = pyblish.api.CollectorOrder | ||
hosts = ["houdini"] | ||
families = ["pointcache"] | ||
label = "Collect type of pointcache" | ||
|
||
def process(self, instance): | ||
if instance.data["creator_identifier"] == "io.openpype.creators.houdini.bgeo": # noqa: E501 | ||
instance.data["families"] += ["bgeo"] | ||
elif instance.data["creator_identifier"] == "io.openpype.creators.houdini.alembic": # noqa: E501 | ||
instance.data["families"] += ["abc"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import os | ||
|
||
import pyblish.api | ||
|
||
from openpype.pipeline import publish | ||
from openpype.hosts.houdini.api.lib import render_rop | ||
from openpype.hosts.houdini.api import lib | ||
|
||
import hou | ||
|
||
|
||
class ExtractBGEO(publish.Extractor): | ||
|
||
order = pyblish.api.ExtractorOrder | ||
label = "Extract BGEO" | ||
hosts = ["houdini"] | ||
families = ["bgeo"] | ||
|
||
def process(self, instance): | ||
|
||
ropnode = hou.node(instance.data["instance_node"]) | ||
|
||
# Get the filename from the filename parameter | ||
output = ropnode.evalParm("sopoutput") | ||
staging_dir, file_name = os.path.split(output) | ||
instance.data["stagingDir"] = staging_dir | ||
|
||
# We run the render | ||
self.log.info("Writing bgeo files '{}' to '{}'.".format( | ||
file_name, staging_dir)) | ||
|
||
# write files | ||
render_rop(ropnode) | ||
|
||
output = instance.data["frames"] | ||
|
||
_, ext = lib.splitext( | ||
output[0], allowed_multidot_extensions=[ | ||
".ass.gz", ".bgeo.sc", ".bgeo.gz", | ||
".bgeo.lzma", ".bgeo.bz2"]) | ||
|
||
if "representations" not in instance.data: | ||
instance.data["representations"] = [] | ||
|
||
representation = { | ||
"name": "bgeo", | ||
"ext": ext.lstrip("."), | ||
"files": output, | ||
"stagingDir": staging_dir, | ||
"frameStart": instance.data["frameStart"], | ||
"frameEnd": instance.data["frameEnd"] | ||
} | ||
instance.data["representations"].append(representation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
openpype/hosts/houdini/plugins/publish/validate_bgeo_file_sop_path.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Validator plugin for SOP Path in bgeo isntance.""" | ||
import pyblish.api | ||
from openpype.pipeline import PublishValidationError | ||
|
||
|
||
class ValidateNoSOPPath(pyblish.api.InstancePlugin): | ||
"""Validate if SOP Path in BGEO instance exists.""" | ||
|
||
order = pyblish.api.ValidatorOrder | ||
families = ["bgeo"] | ||
label = "Validate BGEO SOP Path" | ||
|
||
def process(self, instance): | ||
|
||
import hou | ||
|
||
node = hou.node(instance.data.get("instance_node")) | ||
sop_path = node.evalParm("soppath") | ||
if not sop_path: | ||
raise PublishValidationError( | ||
("Empty SOP Path ('soppath' parameter) found in " | ||
f"the BGEO instance Geometry - {node.path()}")) | ||
if not isinstance(hou.node(sop_path), hou.SopNode): | ||
raise PublishValidationError( | ||
"SOP path is not pointing to valid SOP node.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.