Skip to main content
Skip table of contents

Schema

For every node in a channel there is an associated schema that defines what inputs, outputs, and other attributes are implemented by the node. Schema are stored in schema files in the same directory as the node files. For every node module in the package, there is an associated schema file. Schema files are written in YAML and use the same base name as the corresponding node module, e.g. the schema file for “my_node.py” is “my_node.yml”.

Here is an example schema for the “Add” node defined in the previous section:

YAML
schemas:
  Add:
    inputs:
    - name: Value1
      description: The first value to be added
    - name: Value2
      description: The second value to be added
      default: 1
    outputs:
    - name: Sum
      description: The sum of Value1 and Value2 added together
    tooltip: Add two values and return the sum
    category: Functions
    subcategory: Math
    color: "#0C667A"

The schema file has a single top level element called “schemas” which is a dictionary containing one item for every node defined in the corresponding node module. In this example, the schema file defines a single node called “Add”.

Node input ports are specified as a list of dictionaries, with one list entry per input port. Each input port must specify a name and description. Optionally, a default value for the port can be specified. This value will be used if no value or link is assigned to that port in the graph.

In this example, there are two input ports - “Value1” and “Value2”. The Value2 input port is assigned a default value of 1.

Output ports are specified as a list of dictionaries, with one list entry per output port. Each output port must specify a name and description.

In this example there is one output port - “Sum”.

The “tooltip”, “category”, “subcategory”, and “color” attributes specify information used in the GUI based graph editor.

The “tooltip” attribute specifies a string to be displayed when the user hovers over the (info) symbol on the node.

The “category” and “subcategory” specify where the node will be located in the add-node menu on the left side of the graph editor. In this example, the node will be located under “Functions” → “Math”.

The “color” attribute specifies the color to be used when the node is displayed in the GUI.

Additional attributes can be assigned to input ports to help guide users when they are entering inputs in the GUI. Here is an example:

CODE
schemas:
  Location3d:
    inputs:
    - name: Terrain Type 
      description: The type of terrain to generate for this location
      select:
      - desert
      - forest
      - urban
      default: urban
    outputs:
    - name: Terrain
      description: The terrain for this location
    tooltip: Generate a 3d background to be used in the scene
    category: Locations
    subcategory: Procedural
    color: "#0C667A"

In this example, we define a node called “Location3d” that will procedurally generate 3d terrain. The type of terrain to be generated is specified via the “Terrain Type” input port. The “select” attribute provides a list of values for this port that will be displayed in the GUI as a pull-down menu. The user can scroll through this menu to pick a value. The default value displayed in the pull-down is “urban”.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.