Difference between Inline USD and SdfLayer ImportFromString?

   2101   2   2
User Avatar
Member
27 posts
Joined: Sept. 2016
Offline
Hey Mark,

It has been a long time since the last time we got in touch. I'm working on building the bridge between Houdini and UE these days, and we found Solaris would be a great help for transferring data from one to the other.

To synchronize data rapidly, we're trying to set up a live stream instead of dumping everything to disk. In other words, we expect to import a stage with some python calls like this:
node = hou.pwd()
stage = node.editableStage()
stage.GetRootLayer().ImportFromString(
"""#usda 1.0

def \"sandbox\"
{
    def Mesh \"box\"
    {
        int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
        int[] faceVertexIndices = [1, 5, 4, 0, 2, 6, 5, 1, 3, 7, 6, 2, 0, 4, 7, 3, 2, 1, 0, 3, 5, 6, 7, 4]
        point3f[] points = [(-0.5, -0.5, -0.5), (0.5, -0.5, -0.5), (0.5, -0.5, 0.5), (-0.5, -0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, 0.5)]
    }
}""")

Unfortunately, the above snippet is not effective, at least in my tests. There's a workaround for this is to procedurally editing an Inline USD node. However, I'm interested in the magic of the implementation of the Inline USD node, as the flattened stage of this is the same as the python one…

Cheers,
Calvin
Edited by calving - Feb. 3, 2020 17:06:33
User Avatar
Staff
4438 posts
Joined: July 2005
Offline
Hey Calvin, that is close, but definitely won't work as written.
You are not allowed to modify the stage's root layer directly, or the whole LOP cooking mechanism will break down.
Instead, do:
node = hou.pwd()
layer = node.editableLayer()
layer.ImportFromString(...)
User Avatar
Member
27 posts
Joined: Sept. 2016
Offline
Ahh… Thanks, Mark! It works and everything goes right now.
  • Quick Links