Building custom importers and exporters: Quick Reference — Data Exchange (NVIDIA-Certified Professional: OpenUSD Development)
Quick Reference: Building Custom Importers and Exporters in OpenUSD This guide provides essential facts and best practices for creating custom...
Quick Reference: Building Custom Importers and Exporters in OpenUSD
This guide provides essential facts and best practices for creating custom importers and exporters as part of data exchange workflows in OpenUSD, a key skill for the NVIDIA-Certified Professional: OpenUSD Development exam.
Key Concepts
- Importer: A tool or script that reads external data formats and converts them into OpenUSD scene description format.
- Exporter: A tool or script that writes OpenUSD scene data into external formats for interoperability.
- Data Mapping Document: Defines correspondence between source data schema and OpenUSD schema, guiding import/export transformations.
- Scripting APIs: Python and C++ APIs provided by USD for programmatic control of data interchange.
Steps for Building Custom Importers
- Analyze Source Format: Understand the structure, data types, and semantics of the external format.
- Create Data Mapping Document: Define how source elements map to USD prims, attributes, and relationships.
- Use USD APIs: Utilize UsdStage to create and populate USD scene graph nodes.
- Handle Metadata and Variants: Map source metadata and variant sets appropriately to preserve scene fidelity.
- Validate Output: Verify the generated USD file for correctness and completeness.
Steps for Building Custom Exporters
- Identify Target Format Requirements: Document the expected schema and constraints of the external format.
- Map USD Data: Use the data mapping document to translate USD prims and attributes to target format elements.
- Traverse USD Stage: Iterate over the UsdStage scene graph to extract relevant data.
- Serialize Data: Convert extracted data into the target format's file structure and encoding.
- Test Exported Files: Ensure compatibility and correctness by loading files in target applications.
Best Practices
- Modular Design: Separate parsing, mapping, and serialization logic for maintainability.
- Error Handling: Implement robust error detection and reporting during import/export operations.
- Performance Optimization: Use efficient data access patterns and minimize redundant processing.
- Documentation: Maintain clear data mapping documents and code comments for future updates.
- Leverage USD Utilities: Utilize existing USD schema and utilities whenever possible to reduce custom code.
Common USD APIs for Importer/Exporter Development
- UsdStage::CreateNew() / UsdStage::Open() – Create or open USD stages.
- UsdPrim – Represents scene graph nodes for manipulation.
- UsdAttribute – Access and set attribute values.
- UsdGeom – Geometry schema classes for mesh, curves, etc.
- UsdShade – Shader and material schema for rendering data.
- UsdUtils – Utility functions for common tasks like flattening or composing layers.
Example Snippet: Creating a USD Prim in Python
Task: Create a mesh prim named "MyMesh" under the root.
stage = Usd.Stage.CreateNew("output.usda") mesh_prim = stage.DefinePrim("/MyMesh", "Mesh") mesh = UsdGeom.Mesh(mesh_prim)
Set points, face vertex counts, etc.
mesh.CreatePointsAttr(points) stage.GetRootLayer().Save()
Summary
Building custom importers and exporters in OpenUSD requires a clear understanding of both source/target data formats and the USD scene graph API. Using well-defined data mapping documents and leveraging USD scripting APIs enables efficient, maintainable data interchange pipelines essential for professional OpenUSD development.
More in this topic
Preparing for the NCP-OUSD exam?
Start free with 5 practice quizzes a day and track your progress.
Practise NCP-OUSD questions free →