Daniel Raymond

draymond

About Me

Many Hats FX / Pipeline Person
EXPERTISE
VFX Artist
INDUSTRY
Film/TV

Connect

LOCATION
Canada
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

USD File Extensions and Saving Oct. 19, 2022, 2:40 a.m.

That works. I've gone and included it within an output processor to fit my "default" behaviour needs, and included it here if anyone else finds a need for it.

import hou
import husd.outputprocessor as base
from pxr import Sdf
import pathlib

class UsdFormatOutputProcessor(base.OutputProcessor):
    def __init__(self):
        super().__init__()

    @staticmethod
    def name():
        return 'usdformat'

    @staticmethod
    def displayName():
        return '.USD Format'

    @staticmethod
    def parameters():
        group = hou.ParmTemplateGroup()
        group.append(hou.StringParmTemplate("format", "Format", 1))
        return group.asDialogScript()

    def beginSave(self, config_node, config_overrides, lop_node, t):
        super().beginSave(config_node, config_overrides, lop_node, t)
        self.format = config_node.parm("format").evalAsString()

    def processSavePath(self, asset_path, referencing_layer_path, asset_is_layer):
        obj = pathlib.Path(asset_path)
        if asset_is_layer and obj.suffix == ".usd":
            asset_path = Sdf.Layer.CreateIdentifier(str(obj), {"format": self.format})
            print(".USD Format:", asset_path)
            return asset_path
        return asset_path

################################################################################
# In order to be considered for output processing, this python module
# implements the function that returns a processor object.
#
def usdOutputProcessor():
    return UsdFormatOutputProcessor

USD File Extensions and Saving Oct. 18, 2022, 7:14 p.m.

Is there any option on save/output to prefer ascii vs binary when saving to the .usd extension?

I could see advantages in saving to .usd as opposed to .usda to avoid hard-linking asset path file formats, but I've been finding that Houdini hasn't exposed any options for this?

Does anyone have any alternate strategies to deal with this?

Thanks!

Merging Implicit Layers Oct. 17, 2022, 1:11 p.m.

Managed to deal with my implementation problem using the Python script node with an immediate layer break before it. It's an indiscriminate merge, but it works for my use case. The solution surprised me a bit, as I didn't expect the USD ROP to save anything above the layer break, but it does somehow? I guess because I'm merging things in from above the layer break, including the HoudiniLayerInfo prim. Anyhow, maybe this helps somebody else..

I still think it'd be nice to have the flatten implicit available outside the USD ROP output.

from pxr import UsdUtils
node = hou.pwd()
source_input = node.input(0).input(0)  # Skip over immediate layerbreak
layers = list()
for i in reversed(range(source_input.sourceLayerCount())):
    layers.append(source_input.sourceLayer(i))
target_layer = node.editableLayer()
[UsdUtils.StitchLayers(target_layer, layer) for layer in layers]