Skip to content

Architecture

src/nyx_usd
├── ops
│   ├── __init__.py       imports every operation, the nodes call nyx_usd.ops.<name>
│   ├── _common.py        the opened stages, handles, JSON <-> USD conversion
│   ├── stages.py         open, create, save, close
│   ├── prims.py          add, query, edit prims, kind, active, prim metadata
│   ├── attributes.py     set/get attributes, at a time, list, remove
│   ├── stage_settings.py metadata, time, axis, units, default prim, stage info
│   ├── composition.py    references, payloads, inherits, layers, variants, export
│   └── geometry.py       transforms, bounds, visibility, shapes, meshes, materials
└── version.py            __version__
plugins/usd_plugin
├── nyx_plugin.py         the NyxUsd plugin, registers the nodes
├── nodes
│   ├── usd_node.py       Param, OperationSpec, UsdNode, create_node_class
│   ├── usd_client.py     UsdClientNode
│   ├── operations.py     OPERATIONS: all the specs
│   └── specs             one module per area, the OperationSpec of every node
└── resources             resources.qrc, icons, resources_rc.py (generated by make qrc)

Two halves in two interpreters

nyx_usd plugins/usd_plugin
Runs in The client: an interpreter with pxr Nyx (Python 3.14)
Imports pxr, the standard library nyx.api.v1, the standard library
Is Plain functions, JSON in and out One node class per function
Packaged In the wheel (sowwic-nyx-usd) No: the plugins folder is put on NYX_PLUGIN_PATH

They meet at one place: the name and arguments of a function of nyx_usd.ops.

Operations

Every function in ops takes a stage handle first, and gets JSON values only (numbers, strings, booleans, lists, dictionaries). A function that edits a stage returns its handle, so nodes chain; a function that reads returns the value.

_common.STAGES maps handles to opened Usd.Stage objects. A handle is the identifier of the root layer. The opened stages live as long as the process, until close_stage or close_all. get_stage and get_prim raise a ValueError with the handle or path in the message, which Nyx shows on the node.

_common.to_usd turns a JSON list into the vector, matrix or array an attribute type calls for, and to_json does the opposite for what is read, so a Vec3f is [x, y, z] and a Matrix4d a list of rows.

The functions are imported in ops/__init__.py, because that is what the nodes call.

Nodes

create_node_class makes one UsdNode subclass from an OperationSpec. UsdNode extends Nyx's RemoteActionNode, which already knows how to send code to the client of the enclosing Remote Client node, and overrides its hooks:

  1. setup adds flow, one input per Param, timeout and response. List defaults are copied for every node, so nodes don't share one list.
  2. build_args reads the inputs into a dictionary.
  3. build_script returns the code the client runs:

    import nyx_usd.ops
    result = nyx_usd.ops.<name>(**{name: globals()[name] for name in [...]})
    
  4. The inherited execute sends it with the arguments as variables, waits (with the timeout) and passes the value assigned to result to handle_response, which puts it in response.

execute is not overridden, so the error handling is the one of RemoteActionNode: a function that raises comes back as a RemoteExecutionError with its message.

OperationSpec.tags become the tags of the node ({"usd", "bridge", *tags}), which the palette search understands as tags:<tag>. The Param datatypes come from CoreDatatypes. A stage handle is a plain core:string, there is no datatype of its own.

The USD Client node

UsdClientNode (usd_client.py) extends Nyx's LaunchProcessNode. It reuses all of it, and changes two things:

  • The command input is turned into python (renamed in setup), keeping its place in the node.
  • _build_arguments returns [python, "-c", CLIENT_SOURCE] instead of splitting a command line. The interpreter is the input, or NYX_USD_PYTHON of the environment of the process, and it fails with a clear message if there is neither.

CLIENT_SOURCE is a small nyx_bridge client with the kind usd, connecting under the name Launch Process put in NYX_BRIDGE_CLIENT_NAME (the node waits for exactly that name). The address and token come from the environment Launch Process sets.

How Nyx loads the plugin

Nyx finds nyx_plugin.py files under the folders of NYX_PLUGIN_PATH. It imports the file with the name of its folder as the package, so the relative imports (from .nodes.operations import OPERATIONS) work with no __init__.py files, as in the Nyx stdlib. The modules are named usd_plugin.nyx_plugin.*. Folders like nodes/ and specs/ are namespace packages.

nyx_plugin.py imports resources_rc for its side effect: it registers the icons under :/usd/, which the node classes use as get_type_icon.

Python versions

nyx_usd supports Python 3.11 and newer, the oldest Python of the applications it runs in (Maya 2026 is 3.11). Keep newer syntax out of ops. The plugin runs in Nyx's Python.