|On this page|
This node supports a very specific, hopefully infrequent, production need where you want to replace a layer without disturbing higher layers that already overlay it.
Since USD is designed for non-destructive editing, it’s deliberately impossible to "delete" anything. However, replacing a layer "properly" might involve rebuilding a tree of USD files from the problem layer up.
To avoid that work, this node subverts the USD paradigm a little. First it replaces the layer in memory. Then it loads into memory any layers that use the replaced layer, and rewrites them in-memory so they point to the replacement layer instead.
Note that, after you've replaced the layer and written out modified USD, you should remove this node and the second input branch from the network (unless you did the replacement in a "throw-away" HIP file), since it doesn’t make sense to replace the layer more than once.
Changing file locations
This node can create a large number of (replaced and rewritten) in-memory layers. The Modified Layer Path parameter provides an opportunity to change the file path these modified layers are saved out to. For example, you could add a
_replaced suffix to the filename, or bump a version number, or save to different directory. This can be useful if you need the old pre-replacement files can co-exist with new post-replacement files.
Build the "replacement" layer in a separate node chain of the LOP network.
Create a Layer Replace LOP. Connect the main node chain to the first input, and the chain containing the "replacement layer" to the second input.
In the Replace Layer node’s parameters, set the Replace path to the file path the layer you want to replace was imported from.
Consider changing the save file paths of the modified files using an expression in the Modified layer path parameer.
Write out the modified USD (for example, using a USD render node at the end of the network).
The output files now contain the replaced layer.
Delete the Replace Layer node and the chain connected to its second input.
The file path of the layer you want to replace.
This parameter can specify multiple paths, and use wildcards, which allows it to replace many layers with a single common replacement layer. The pattern is compared to both the original layer reference as it appears in the referencing layer, and as an absolute path (created by treating the referencing layer’s path as the root location to resolve relative paths).
Modified Layer Path
This parameter is evaluated for each modified layer, and should contain an expression that computes the filepath under which the modified layer will be saved. In the expression, the
@oldpath local variable (
$OLDPATH is deprecated) contains the layer’s . (Remember that in a string parameter you must surround expression code with backticks.) The default is just
`@oldpath`, which uses saves the modified layers to the same paths as before.
Note that this path will be run through the output processors when written out just like any other save path.