Directory Structure

It is advantageous to consider nodes as a separate type of thing and structure your directories to make them easier to find. While it’s not required in order to make the build work, it’s recommended in order to keep the location of files consistent.

The standard Kit extension layout has these directories by default:

omni.my.feature/
    bindings/
        Files related to Python bindings of your C++
    config/
        extension.toml configuration file
    docs/
        index.rst explaining your extension
    plugins/
        C++ code used by your extension
    python/
        __init__.py
        extension.py = Imports of your bindings and commands, and a omni.ext.IExt object for startup/shutdown
        scripts/
            Python code used by your extension

The contents of your init.py file should expose the parts of your Python code that you wish to make public, including some boilerplate to register your extension and its nodes. For example, if you have two scripts for general use in a utility.py file then your init.py file might look like this:

"""Public interface for my.extension"""
import .extension
import .ogn

from .scripts.utility import my_first_useful_script
from .scripts.utility import my_second_useful_script

The C++ node files (OgnSomeNode.ogn and OgnSomeNode.cpp) will live in a top level nodes/ directory and the Python ones (OgnSomePythonNode.ogn and OgnSomePythonNode.py) go into a python/nodes/ subdirectory:

omni.my.feature/
    bindings/
    config/
    docs/
    nodes/
        OgnSomeNode.ogn
        OgnSomeNode.cpp
    plugins/
    python/
        nodes/
            OgnSomePythonNode.ogn
            OgnSomePythonNode.py

If your extension has a large number of nodes you might also consider adding extra subdirectories to keep them together:

omni.my.feature/
    ...
    nodes/
        math/
            OgnMathSomeNode.ogn
            OgnMathSomeNode.cpp
        physics/
            OgnPhysicsSomeNode.ogn
            OgnPhysicsSomeNode.cpp
        utility/
            OgnUtilitySomeNode.ogn
            OgnUtilitySomeNode.cpp
    ...

Tip

Although any directory structure can be used, using this particular structure lets you take advantage of the predefined build project settings for OmniGraph nodes, and makes it easier to find files in both familiar and unfamiliar extensions.