The project's Graph represents all nodes of your project.
# Create an instance
from wysilab import InstantTerra
it = InstantTerra()
# Get the current graph
graph = it.project.graph
# Returns the numbers of nodes in the graph
number_of_nodes = graph.get_node_count()
print(number_of_nodes)
See get_node_count()
in the documentation.
# Returns the list of nodes in the graph
list_of_nodes = graph.get_all_nodes()
The get_all_nodes()
method lists the nodes of the graph.
Tip
More information about the nodes is found in the section Accessing node data.
# Add a node in the graph
newNode = graph.add_node(ApiNodeType.PERLIN_NOISE, (10, 10))
The add_node(ApiNodeType, tuple(int, int))
method creates a node on the graph at the specified location, and
returns the new node.
# Add a node in the graph next to another one
newNode = graph.add_node_next_to(ApiNodeType.PERLIN_NOISE, NodeLocation.Right, previous_node)
The add_node_next_to(ApiNodeType, NodeLocation, Node)
method creates a node on the graph
next to a specified node, and returns the new node.
# Remove a node from the graph
graph.remove_node(nodeToRemove)
The remove_node(Node)
method removes the node
from the graph.
# Get connectors
start_connector = perlin_node.get_connectors()[ConnectorMode.Output][0] # Has only one output connector
end_connector = apply_curve_node.get_connectors()[ConnectorMode.Input][0] # Has only one output connector
# Add a link between two nodes
link = graph.add_link(perlin_node, start_connector, apply_curve_node, end_connector)
The add_link(start_node, start_connector, en_node,
end_connector)
method creates a
link between two nodes of the graph.
# Add a link between two nodes
link = graph.add_link_using_name(perlin_node, "output_terrain_1", apply_curve_node, "input_terrain_1")
The add_link_using_name(start_node, start_connector_name, en_node, end_connector_name)
method creates a link
between two nodes of the graph.
# Remove a link
graph.remove_link(perlin_link)
The remove_link(Link)
method removes the
link.
Copyright © 2022 · All Rights Reserved · Wysilab