Class Node

class node.Node

This class represents an InstantTerra node.

>>> from wysilab import InstantTerra
>>> it = InstantTerra()
>>> my_node = it.project.graph.get_all_nodes()[0]  # Get the first node

Node.has_parameter(parameter_name)

Parameters

parameter_name (str) : Name of the parameter.

Returns

True if the parameter exists, otherwise False.

Return type

bool

>>> my_node.has_parameter("offset_x")
True
>>> my_node.has_parameter("unknown")
False

Node.get_parameter_list()

Returns

List of parameters name.

Return type

list (of str)

Returns the list of node parameters name.

>>> my_node.get_parameter_list()
['file_name', 'user_defined_range', 'min_height', 'max_height']

Node.get_parameter(parameter_name)

Parameters

parameter_name (str) : Name of the parameter.

Returns

Value of the parameter.

Return type

str

Raises

IndexError − Raise an exception if the parameter name was not found.

Returns the value of the parameter.

>>> my_node.get_parameter("max_height")
'200.0'

Node.set_parameter(parameter_name, value)

Parameters
  • parameter_name (str) : Name of the parameter.

  • value (str) : Value to set.

Raises
  • IndexError − The parameter name was not found.

  • ValueError − The value cannot be set (i.e. wrong type).

Sets the value of the parameter.

>>> my_node.set_parameter("max_height", "100.0")
>>> my_node.get_parameter("max_height")
'100.0'

Node.get_connectors()

Returns a dictionnary of connectors of the Node.

>>> my_node.get_connectors()
{<ConnectorMode.MandatoryInput: 0>: [Connector<...>], <ConnectorMode.OptionalInput: 1>: [], <ConnectorMode.Output: 2>: [Connector<...>, Connector<...>]}

Node.name

Type

str

Name of the node.

>>> my_node.name = "MyNodeName"
>>> print(my_node.name)
MyNodeName

Node.comment

Type

str

Comment of the node.

>>> my_node.comment = "A simple commentary"
>>> print(my_node.comment)
A simple commentary

Node.type

Type

str

Raises

ValueError − Impossible to override this attribute.

Type of node.

>>> print(my_node.type)
Perlin noise

Node.is_enabled

Type

bool

True if the node is enabled, False if it is disabled.
node_is_enabled = my_node.is_enabled
my_node.is_enabled = False

Node.get_maximum_value

Type

float

Raises

ValueError − The node does not have an output terrain or mask.

Maximum elevation of the terrain in meters/ maximum value of the mask between 0 and 1

Calling this method triggers the calculation of the node if not already done. When the project contains a lot of nodes, this calculation may last several seconds to several minutes.
If the node contains several output terrains or masks (such as erosion nodes), the first terrain or first mask is used.

As export nodes do not have any output terrain or mask, the method has to be called from the previous node.

>>> my_node.get_maximum_value()
120.5

Node.get_minimum_value

Type

float

Raises

ValueError − The node does not have an output terrain or mask.

Minimum elevation of the terrain in meters/ minimum value of the mask between 0 and 1

Calling this method triggers the calculation of the node if not already done. When the project contains a lot of nodes, this calculation may last several seconds to several minutes.
If the node contains several output terrains or masks (such as erosion nodes), the first terrain or first mask is used.

As export nodes do not have any output terrain or mask, the method has to be called from the previous node.

>>> my_node.get_minimum_value()
-12.3

Copyright © 2022 · All Rights Reserved · Wysilab