Creating Python Nodes
This is a guide to writing a node in Python, including how to set up and structure everything you need in your extension so that the node can be delivered to others in a consistent way. You may already have some of the pieces in place - feel free to skip ahead to just the parts you will need.
If you wish to create a C++ node then see Creating C++ Nodes.
Setting Up Your Extension
The Omniverse applications rely on extensions to provide functionality in a modular way and the nodes you write will be integrated best if you follow the same model.
You may choose to add much more to your extension. What is described here is the bare minimum required to make an extension containing a single Python node integrate into a Kit-based application.
Whether you are familiar with extension development in Kit or not, the best place to start is from one of the predefined template extensions.
Note
If you will have a mixture of both C++ and Python files in your extension then you should instead use this template that sets up an extension with both kinds of nodes.
Python Nodes With A Build
The typical method of creating OmniGraph Python nodes is to use a build process with a .ogn definition file to generate Python support code, documentation, and even automated tests for your node type.
Once you have a build directory you can copy the template extension
omni.graph.template.python into your source/extensions
directory so that
the build process can access it.
See that extension’s documentation for a more thorough explanation of how to populate and build your Python nodes once the extension is in place.
Python Nodes Without A Build
If you want to get up and running faster without the overhead of a build you can build a much smaller extension. This
type of extension can only contain Python files, documentation, data, and configuration files such as the mandatory
config/extension.toml
file.
You can define a local extension in your Documents/Kit/shared/exts
directory, which will be
automatically scanned by the extension manager.
A template for an extension with no build process can be found in
omni.graph.template.no_build. You can copy this directory into your
Documents/Kit/shared/exts
directory, which will be automatically scanned by the extension manager. Be sure to
rename everything to match your own extension’s requirements.
See that extension’s documentation for a more thorough explanation of how to build your Python nodes once the extension is in place.
To see details of what capabilities the Python node and its corresponding .ogn definition have look through some examples in the OGN User Guide, or look at some nodes that have already been implemented in the node library reference.
See in particular the OGN Code Samples - Python for examples of how to access different types of data within a node.
To see details of what capabilities the Python node and its corresponding .ogn definition have look through some examples in the OGN User Guide, or look at some nodes that have already been implemented in the node library reference).