Accessing node data

What is a graph "node"?

A node represents an operation in InstantTerra, i.e. the generation of a terrain using a noise or even an erosion simulation.

These nodes and their parameters are accessible directly via the API.

# Create an instance
from wysilab import InstantTerra
it = InstantTerra()

# Get the current graph and the list of nodes
graph = it.project.graph
list_of_node = graph.get_all_nodes()

# Get the first node of the graph
my_node = list_of_node[0]

Changing a node name

my_node.name = "New name"
print(my_node.name)

To change or retrieve a node name, use the attribute name.

Changing a node comment

my_node.comment = "This is a commentary"
print(my_node.comment)

To change or retrieve a node comment, use the attribute comment.

Retrieving the node type

print(my_node.type)

To retrieve the node type, use the attribute type.

Retrieving the parameters' list

# Returns the list of node parameters
list_of_parameters = my_node.get_parameter_list()
print(list_of_parameters)

The method get_parameter_list() returns the list of node parameters.

Determining if a parameter exists

# Returns True if the parameter exist
print(my_node.has_parameter("ParameterName"))

See has_parameter(parameter_name) in the documentation.

Retrieving or setting a parameter value

# Get the value of the parameter
print(my_node.get_parameter("offset_x"))

# Set the value of the parameter
my_node.set_parameter("offset_x", "1.0")

See get_parameter(parameter_name) and set_parameter(parameter_name) in the documentation.

Note

If the parameter name does not exist o

r if the set value is not valid, Python returns an error message with the description of the problem.


Copyright © 2020 · All Rights Reserved · Wysilab