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:
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 “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:
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”.
Last updated