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