Basic API Usage

Writing to the NDK API is quite similar to writing to the USD API. Here are some examples of performing common tasks.

Defining a Prim

Here’s how to define a mesh prim in a layer:

usg::Path path(“/path/to/my/mesh”);
usg::Layer* layer = editLayer(); // See later
usg::MeshPrim prim = usg::MeshPrim::defineInLayer(layer, path);

Overriding an existing prim is similar:

usg::MeshPrim prim = usg::MeshPrim::overrideInLayer(layer, prim);

Getting and Setting Attributes

Creating an attribute:

usg::Attribute attr = prim.createAttr("outputs:surface", usg::Value::Token);
usg::Attribute attr = prim.createAttr("wobbliness", usg::Value::Float, true);

Getting an attribute:

usg::Attribute attr  = Prim::getAttr(usg::GeomTokens.points);
usg::Vec3fArray points;
attr.getValue(points, time);

Setting an attribute:

attr.setValue(points, time);


It’s possible to get to the underlying wrapped USD values for these objects. For example, you can get the raw UsdStageRefPtr for a stage and manipulate it in C++ or Python, but we’re discouraging this if you can do what you want in the NDK API.