using pxr; // open a USD file var stage = UsdStage.Open("path/to/file.usd"); // get all prims in the stage var prims = stage.Traverse(); // print the names of all the prims foreach(var prim in prims) { Debug.Log(prim.GetPath().ToString()); }
using pxr; // create a new USD stage var stage = UsdStage.CreateNew("path/to/new/file.usd"); // create a new mesh var meshPrim = stage.DefinePrim(new SdfPath("/myMesh"), "Mesh"); // add a triangle to the mesh var points = new VtVec3fArray(3); points[0] = new Vector3(0, 0, 0); points[1] = new Vector3(1, 0, 0); points[2] = new Vector3(0, 1, 0); var mesh = new UsdGeomMesh(meshPrim); mesh.CreatePointsAttr().Set(points); // save the stage to disk stage.Save();These examples demonstrate how UsdCsPINVOKE can be used to read and write USD files in C#. UsdCsPINVOKE is part of the Pixar USD library, which is an open-source project for creating, editing, and viewing 3D scenes.