Basic API Usage =============== Here are some examples of performing common tasks. Defining a Prim --------------- Here’s how to define a mesh prim in a layer: .. code-block:: cpp usg::Path path("/path/to/my/mesh"); usg::Layer* layer = editLayer(); usg::MeshPrim prim = usg::MeshPrim::defineInLayer(layer, path); Overriding an existing prim is similar: .. code-block:: cpp usg::MeshPrim prim = usg::MeshPrim::overrideInLayer(layer, prim); Getting a prim from a node: .. code-block:: python node = NodegraphAPI.GetNode("MyNodeName") stage = NodesUsdAPI.GetStage(node) prim = stage.getPrimAtPath("/path/to/my/prim") Getting and Setting Attributes ------------------------------ Creating an attribute: .. code-block:: cpp usg::Attribute attr = prim.createAttr("outputs:surface", usg::Value::Token); usg::Attribute attr = prim.createAttr("wobbliness", usg::Value::Float, true); Getting an attribute in C++: .. code-block:: cpp usg::Attribute attr = Prim::getAttr(usg::GeomTokens.points); usg::Vec3fArray points; attr.getValue(points, time); Getting an attribute in Python: .. code-block:: python attr = prim.getAttr("points") points = attr.get() Setting an attribute in C++: .. code-block:: cpp attr.setValue(points, time); Setting an attribute in Python: .. code-block:: python usgValue = usg.Value(usg.Vec3fArray([usg.Vec3f(1.1111), usg.Vec3f(2.2222)]), usg.Value.Float3Array) attr.set(usgValue) Raw USD ------- 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.