flatten_usd_stage
Export a flattened copy of a USD stage to .usd/.usda/.usdc/.usdz without changing the in-memory stage; use it to save a portable, provenance-tagged snapshot.
Instructions
Export a flattened copy of the stage to a .usd/.usda/.usdc/.usdz file (the file writer is chosen by the extension). Wraps UE::FUsdStage::Export(OutputPath, bAddSourceFileComment, FileFormatArguments) — does NOT alter the in-memory stage. When add_source_file_comment is true (default) the flattened file includes a comment header noting the source file (useful for provenance). The returned 'exported' field reports pxr::'s bool return — false means the file writer could not write the requested path (e.g. invalid extension, permission denied). Realistic gotcha: stage.Export() requires the stage NOT be in a restricted-edit state — under headless cov this is not an issue, but in-editor it can be during PIE.
Returns: { stage_name: string, resolution: string, output_path: string, exported: bool, add_source_file_comment: bool, errors: [string]? }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stage_name | Yes | Name the stage was registered under, OR an absolute file path to auto-open. | |
| output_path | Yes | Absolute path of the flattened file to write. The file extension picks the writer (.usda=text, .usdc=binary, .usdz=archive). | |
| add_source_file_comment | No | Include the source-file comment header in the flattened file (default true). |