Creating nodes

Streams provide a number of ways of creating nodes. These methods are summarized in the following table.

Table 1. Methods for creating nodes
Method Return type Description
s.create(nodeType, name) Node Creates a node of the specified type and adds it to the specified stream.
s.createAt(nodeType, name, x, y) Node Creates a node of the specified type and adds it to the specified stream at the specified location. If either x < 0 or y < 0, the location is not set.
s.createModelApplier(modelOutput, name) Node Creates a model applier node that is derived from the supplied model output object.

For example, to create a new Type node in a stream you can use the following script:

stream = modeler.script.stream()
# Create a new type node
node = stream.create("type", "My Type")