Creating explicit save layers with Python

   392   2   1
User Avatar
Member
285 posts
Joined:
Offline
Hello,

I'm not sure where to find this info: is it possible, using only Python, to build a stage similar to the way stages are defined in a LOP network, where one can build and layer anonymous layers and then save them all to separate explicit paths using the USD ROP?

Here is what I would like to do:
- take the Solaris stage as an argument to a script in a Python LOP
- on this stage object, import various files, and create a USD layer for each. Add an explicit save path to each (but don't save yet!).
- build a hierarchy of layers using these imported files
- take the resulting stage output of the Python LOP, then save everything with a USD ROP

What I have tried to do so far in Python for each created layer is:
- create an anonymous layer and add prims
- create a "HoudiniLayerInfo" prim in the anonymous layer
- set the attribute "HoudiniSaveControl" to "explicit"
- set the "HoudiniSavePath" to my desired path

I hoped this parlor trick would convince Solaris to save my custom layers, but it did not seem to do so. The USD ROP just saved my root layer and ignored the anonymous ones, even though they had the save info prim embedded.

Is there a better way to do this? I'm aware I can just save the layers as I create them, but wanted to utilize the LOP output processors.
User Avatar
Staff
4438 posts
Joined: July 2005
Offline
One more thing you need to do to get the USD ROP to save your anonymous layers: create the anonymous layer with a "tag" argument of "LOP". This is how the USD ROP identifies layers as having been authored by the LOP network.

Note that everything else you're doing here is correct, and in fact there is a python method loputils.createPythonLayer that encapsulates all this so you don't actually need to know all these details. Just pass it the hou.LopNode that is creating the layer (hou.pwd() when inside a Python LOP) and pass in a save path where you want the layer to be saved.
User Avatar
Member
285 posts
Joined:
Offline
That did it! Thanks for the tip. Very cool to see this works!

EDIT: BTW, I did it manually instead of using loputils to keep the core code free of Houdini dependencies.
Edited by jparker - March 27, 2024 00:51:34
  • Quick Links