I have a question about UsdUtilsFlattenLayerStack and its behaviour with “add rel”.
The documentation for UsdUtilsFlattenLayerStack
A few historical scene description features cannot be flattened into a single opinion because they unfortunately encode operations that are not closed under composition. Specifically, the SdfListOp operations “add” and “reorder” cannot be flattened. Instead, “add” will be converted to “append”, and “reorder” will be discarded.
We’re finding that “add” is causing the relationship to be cleared, but “append” works fine, so we’re unclear what the documentation means.
This USD file demonstrates the issue:
#usda 1.0
def Scope "A" { }
def Scope "B" { add rel test = </A> }
If I run this Python code:
from pxr import Usd, UsdUtils
stage = Usd.Stage.Open('test.usda')
flat = UsdUtils.FlattenLayerStack(stage)
stage = Usd.Stage.Open(flat.identifier)
print(stage.ExportToString())
The result is that the test relationship ends up empty. If I change “add” to “append” in the USD, the relationship ends up with the original value.
Is this expected behaviour for UsdUtilsFlattenLayerStack, and if so, could the documentation be made clearer?
We came across this problem with the PointInstancedMedCity example, which sets its prototypes with “add rel =”.