We have a USD pipeline that use referencing heavily but sometimes we want to ship of a flatten USD file to 3rd parties.
Problem is, if we flatten the stage the variant sets get also resolved (removed) and only the current selected one remains in the stage. We would like to keep them, so our partners can still switch the variants.
How do do this the best way?
We don’t provide any means of flattening while preserving variants (or any particular arcs), because in general it can become impossible to tease out the “preserved” contributions from those that are getting flattened. Also, variantSets can be nested, etc.
If your scenario is simple with a single variantSet, you could iterate over the variants, flattening each, using SdfCopySpec to bring all the results into a single layer, and construct a root prim spec that recreates the variantSet and references the flattened results in each variant…
But if your goal is simply to package up an asset to ship to someone, while removing the details of your asset management, can you make use of usdz ? The
usdzip —asset utility will create a package for you that contains all needed (localized) referenced usd layers, plus any images/textures the scene requires, and all composition will be retained.