Hi Oli,
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.